Python Network data acquisition first day

Source: Internet
Author: User

FINDALL (tag, attributes, recursive, text, limit, keywords)

Find (tag, attributes, recursive, text, keywords)

Tag parameter tag: Pass the name of a label or multiple label names Python list to do label parameters

the attribute parameter attributes is used with a python A dictionary encapsulates several properties and corresponding property values for a label

The recursive parameter recursive is a Boolean variable. How many layers of information do you want to crawl in the HTML document tag structure? If recursive is set to True, FindAll will find all the child tags of the label parameters and sub-labels of the child tags according to your requirements. If recursive is set to False, FindAll only finds the first-level label of the document. FindAll default is to support recursive lookups (the recursive default value is True);

Text parameter the text is matched with the textual content of the label, not the attribute of the label

In the BeautifulSoup library, all child tags are descendant tags, but not all descendant tags are sub-tags. If you only want to find the sub-tags, you can use the. Children tag

BeautifulSoup's next_siblings () function can make it easy to collect tabular data.

When crawling Web pages, finding the parent tag is a lot less demanding than finding child tags and sibling tags. Usual situation

, if you are looking at HTML pages for the purpose of crawling Web content, we start with the top

Think about how to locate the block where we want the data to be located. However, occasionally in special cases you will also use

BeautifulSoup The parent tag lookup function, parent and parents.




This article from "Big Plum" blog, reproduced please contact the author!

Python network data acquisition first day

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.