[Python Tutorial] image extraction algorithm for webpage body and content

Source: Internet
Author: User
Regular expressions are usually used to capture the content of a single website. However, the structures of different websites are strange, and it is difficult to use a unified regular expression for matching. The author of the generic web page text extraction algorithm based on the Row block Distribution function summarizes the methods for extracting the text from the web page, and proposes a text extraction algorithm based on the Row block distribution, and provides PHP, Java, and other implementations. The main principle of this algorithm is based on two points: regular expression matching is often used to capture the content of a single website webpage. However, the structures of different websites are strange, and it is difficult to use a unified regular expression for matching. The author of the generic web page text extraction algorithm based on the Row block Distribution function summarizes the methods for extracting the text from the web page, and proposes a text extraction algorithm based on the Row block distribution, and provides PHP, Java, and other implementations. The main principle of this algorithm is based on two points: 1. body area density: after all tags in HTML are removed, the character density in the body area is higher, with fewer blank lines; 2. Row block length: the content of a non-body area is generally shorter than that of a separate label (Row block. The algorithm steps are as follows:

1. remove all tags, including style and Js script content, but retain the original line break \ n

The above is the content of the image extraction algorithm for the webpage body and content in the [python Tutorial]. For more information, see The PHP Chinese website (www.php1.cn )!

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.