BeautifulSoup Common methods

Source: Internet
Author: User
#输出所得标签的 ' property value
Gets the content value of the first meta inside the head

soup.head.meta[' content ']
Get the contents of the first span

Soup.span.string
Get the contents of the first span
Soup.span.text

The Name property is called keywords all objects
Soup.find_all (attrs={' name ': ' keywords ')

Get style site_name All tags
Soup.find_all (class_= ' site_name ')

Soup.find (attrs={' name ': ' keywords ') gets the first property name the name value is the label of the keywords
Soup.find (' meta ', attrs={' name ': ' keywords '}) gets the first meta tag the Name property is the keywords label

Print (Soup.find (' meta ', attrs={' name ': ' keywords ') [' content ']) gets the first META tag Name property value is keywords content value

Print (Soup.find (' meta ', attrs={' name ': re.compile (' keywords ', re. IGNORECASE)}) gets the first meta tag the Name property value is a case-insensitive keywords label

BeautifulSoup Common methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.