Overall crawling Process

Source: Internet
Author: User

I. Differences between heritrix and nutch

Heritrix is an "archival crawler"

(1) It is used to obtain complete, accurate, and in-depth replication of site content. Including obtaining images and other non-text content. Capture and store related content. Do not reject content visitors, and do not modify the content on the page.

(2) re-crawling does not replace the previous one with the same URL. Crawlers can start, monitor, and adjust Web user interfaces to flexibly define URLs to be obtained.

Nutch only obtains and stores the content that can be indexed. You can trim the content or convert the content format. Save the content as a database optimized format to facilitate future indexing;

 

2. nutch consists of two parts: crawler and query searcher. Crawler is mainly used to capture webpages from the Internet and create indexes for these webpages. Searcher mainly uses these indexes to retrieve users' search keywords to generate search results.

 

Iii. Procedure

Initialize crawldb, generate a crawling work list, capture web files, update crawldb, inverted links, create indexes, copy index files, and merge index files

1), inject URLs

Org. Apache. nutch. Crawl. Injector

Inject and capture URLs. Because the web page needs to be captured by the crawling program of nutch, You need to specify a URL to locate a (or some) web page. On this basis, the web page captures the content according to the breadth traversal policy, based on the specified URL (which can be a URL set: URLs.

The specific format is <text, crawler>. The key indicates the URL address, and the value is a type "crawldatum" defined by nutch. This type implements the "writable" interface to indicate certain page attributes.

The specific form of the "crawldatum" class is as follows:

Package org. Apache. nutch. Crawl;

Public class crawldatum implementswritablecomparable <crawldatum>, cloneable {

Privatebyte status;

Privatelong fetchtime = system. currenttimemillis ();

Privatebyte retries;

Private intfetchinterval;

Privatefloat score = 1.0f;

Privatebyte [] Signature = NULL;

Privatelong modifiedtime;

Privateorg. Apache. hadoop. Io. mapwritable metadata;

}

These attributes include Page Status, capture time, and capture interval.

The implementation of "injector" in nutch is divided into four steps. The first two steps are two mapreduce tasks.

The first M/R task is used to filter and normalize the URLs in text files, package them into "crawldatum", and finally save them as temporary sequence files. The format of the temporary file is <key, crawldatum>.

The second M/R task is used to merge the sorted results with the data (if any) in the original "crawldb" to generate a new crawler LDB file.

Step 3: replace the original file with the newly generated crawldb.

Step 4: Delete the temporary files generated earlier.

 

2) generate segment

Org. Apache. nutch. Crawl. Generator

Generate a segment. The nutch crawler needs to capture many pages. What are the specific pages? Of course, it is located on the Internet through URLs.

This step mainly analyzes the URL set submitted in the previous step to determine the detailed information of the capture task.

Path segment = generator. Generate (crawler LDB, segments,-1, topn, system. currenttimemillis ()).

Create a file with the system. currenttimemillis () Time identifier under the segments directory, such as 20090806161707,

In addition, traverse crawldb,

Retrieve the URLs whose fetch is required for topn,

Stored in the segments/20090806161707/crawl_generate file, and the crawl_generate is a sequencefile.

 

3) Fetch list

Org. Apache. nutch. Fetcher. fetcher

After analyzing the submitted URL set, capture the page content and store it in the Segment directory.

During the crawling process, the URL address of the page may be changed because of the link, so the URL address needs to be updated;

Multi-threaded crawling to increase the crawling speed;

The parse operation is called during the fetch operation.

Fetcher = new fetcher (CONF );

Fetcher. Fetch (segment, threads, parsing );

The segment is the path, that is, a sequence generated in generate. The default value is 10 fetchthreads. And perform parse in the fetch process.

The entire fetcher process has only one mapreduce job:

Input: crawl_generate, that is, the fetchlist generated in generator. In the generator process, nummaptask is used to split the final generator list, so that each mapper is responsible for capturing part of the fetchlist during The fetcher process.

 

4) content parser

Org. Apache. nutch. parse. parsesegment

Content parser. The captured page file is submitted here to process the page file, including analysis and processing of the page file.

 

5). parsed text & Data

The execution result is: parse the page obtained by fetch into text and data and save it in the segments directory.

Parse the page obtained by fetch in the segment, and sort the page into parse-date and parse-text;

Parse-date stores the title, author, date, and link of the page;

The text content of the page is saved in parse-text.

By performing the preceding steps, you have created the following directories:

Content, fig, parse_data, parse_text

Content

Contains the original number of download pages, stored as a map file in the format of <URL, content>. In order to display the cache and page views, we use files to store data, because the nutch requires fast and random access to the files.

Crawl_generate

It contains the list of URLs to be crawled and the current status information related to these URL pages obtained from crawldb. The format of the corresponding sequential file <URL, crawldatum>. This data is stored in ordered files for two reasons: first, the data is processed in order one by one; second, the immutability of the Map File Sorting value cannot meet our requirements. We need to distribute URLs belonging to the same host as much as possible to reduce the load on each target host, which means that the fierce information is basically randomly arranged.

Crawl_fetch

It contains the status information of Data crawling, that is, the corresponding code for whether the crawling is successful, and so on. The data is stored in the map file in the format of <URL, crawler>.

Crawl_parse

The output Link List of each page that is successfully crawled and parsed is saved here. Therefore, through learning a new URL, nutch can expand its crawling to the front-end page.

Parse_date

The metadata collected during parsing, including the list of outgoing links (frontier) on the page. This information is critical for establishing an undirected graph (Inbound Link-ink.

Parse_text

The plain text content of the page is suitable for indexing with Lucene. These plain text files are stored as map files in the format of <URL, parsetext>. Therefore, when you want to display the summary information (abstract) of the search result list, nutch can quickly access these files.

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.