Home >Web Front-end >HTML Tutorial >beautifulsoup4 description, it is an html parser, the usage is as follows: _html/css_WEB-ITnose
Beautifulsoup4 description, it is an html parser, the usage is as follows:
soup = BeautifulSoup(html_doc)
print soup.title //Get an element
print soup.title .name //Get an attribute of an element
print soup.title.string //Get the text under an element with the same function as soup.title.get_text()
print soup.p
print soup.a
print soup.find_all('a')//Find all specified elements based on the element name or attribute value
print soup.find(id='link3')//Based on the element name or Attribute value, find the first matching element
print soup.get_text()//Get the text under an element
6.feedparser usage instructions, it can parse a url seed and convert it Classify the content to create a dictionary and objectify it. The usage method is as follows:
import feedparser
llog = feedparser.parse("http://languagelog.ldc.upenn.edu/nll/?feed=atom" )
llog['feed']['title'] gets the title of the seed, which is equivalent to llog.feed.title