Home  >  Article  >  Web Front-end  >  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: _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:40:391100browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn