Python crawler RP+BS4

Source: Internet
Author: User

Soup = BeautifulSoup (Html_doc)

Soup is BeautifulSoup processing the formatted string, Soup.title get the title tag, SOUP.P gets the first P tag in the document, to get all the tags, you have to use Find_all

Function.

The Find_all function returns a sequence that loops through it, and then gets the thought in turn.

Get_text () is the return text, which is the label of every BeautifulSoup processed object. You can try print soup.p.get_text ()

In fact, you can get other properties of the tag, such as I want to get the value of the href attribute of the A tag, can use print soup.a[' href ', similar to other properties, such as Class is also available (soup.a[' class ').

In particular, some special tags, such as head tags, can be obtained through soup.head, in fact, the front has already said.

Python crawler RP+BS4

Related Article

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.