Python Learning notes-crawler crawling strategies

Source: Internet
Author: User
1 Depth-First algorithm

2 breadth/Width priority policy

3 Complete binary Tree traversal results

Results of depth-first traversal: [1, 3, 5, 7, 9, 4, 12, 11, 2, 6, 14, 13, 8, 10]

Results of breadth-first traversal: [1, 3, 2, 5, 4, 6, 8, 7, 9, 12, 11, 14, 13, 10]

4 How to combine crawl strategies in practice

(1) In general, important pages are close to the entrance site;

(2) Breadth/width preference is advantageous to multi-crawler parallel cooperation;

(3) Consider combining depth and breadth/width to achieve a crawl strategy: prioritize breadth first and limit depth to depths.

The flow of 51 general purpose crawlers is as follows

(1) Setting the seed site, width and depth

(2) a downloaded queue to record all URLs that have completed the download

(3) Implement a function that obtains the contents of the current URL and all the external links

(4) Recursively call this function to traverse the Web site

(5) Error log processing

Python Learning notes-crawler crawling strategies

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.