python - Only print content between tags -


I am working on a project for my food science class, for which I have to research but why do When do you do something for you? However, I am using Python 2.7 and beautiful Soup with URLIB2 and help to know how to print the content between tags and not just tag yourself, so that I can only copy And what will it take for me in Google Dock? This is my code Thank you very much I am using any help!

  BeautifulSoup import, urllib2, beautiful soup import time from time * print ("belly-vz-cure") url = urllib2.urlopen ("http://www.webmd.com/diet/ belly-fat-diet ") content = url.read () soup = beautiful soup header (content) header = soup.fandall (" h3 ") texts = soup.fildall (" p ") print (header) print (texts) The time of Sleep (5) print ("cabbage soup DIT information") url = urllib.orlopen ("http://www.webmd.com/diet/cabbage-soup-diet") content1 = url.read () soup1 = beautiful soup (Content1) header1 = soup.find all ("h3") texts1 = soup.findle ("p") print (header 1) print (text1)   attribute:  

import urllib2 to bs4 import Beautiful soup soup = beautiful soup (urlib2.urlopen ("http://www.webmd.com/diet/belly-fat-diet")) Print ([header.text for headers in soup. Print (

Print:

  find_all ("h3")) [U 'promise', do you work? ', ...] [u'common conditions', u 'fashionable topics', ...]   

Note that the version I'm using in the example is also - Third edition is no longer developed and maintained. / P>

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -