A topic crawler method and system based on TextCNN

The TextCNN scorer model is used to score web page features and optimize URL distribution, which solves the inefficiency problem caused by crawling irrelevant web pages in the existing technology and realizes an efficient and accurate topic crawler system.

CN114117177BActive Publication Date: 2024-09-17SMART FUSION LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111319822.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-09
Publication Date
2024-09-17
Estimated Expiration
2041-11-09

AI Technical Summary

Technical Problem

Existing topic crawler systems tend to crawl irrelevant web pages during the crawling process, resulting in low efficiency and failure to effectively utilize the structure and text features of web pages.

Method used

A scorer model based on TextCNN is used to extract web page features through HTML parsing. The convolutional layer and the pooling layer are combined to extract and reduce the dimension of anchor text features. The cross-entropy loss function is used for classification. URLs with high scores are allocated first to improve Crawling efficiency.

Benefits of technology

It significantly improves the accuracy and efficiency of web page crawling, reduces the crawling of irrelevant URLs, and enhances the system's scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114117177B
    Figure CN114117177B
Patent Text Reader

Abstract

The present application discloses a method and system for a topic crawler based on TextCNN, the method comprising: initiating a request to a target URL webpage to download the webpage, returning the downloaded html page; receiving the downloaded html page, and performing HTML parsing; storing the time ID, URL link, URL upper link, URL anchor text, webpage title and body of the webpage after HTML parsing; storing metadata consisting of URL and URL score value at the same time; after completing HTML parsing of all URLs, first using a trained scorer model to score the topic relevance and store the URL and URL score, and then distributing URL seeds according to the score result; wherein the scorer model is a convolutional neural network composed of an input layer, a convolution layer, a pooling layer, a fully connected layer and an output layer. The present application overcomes the problem of low crawling efficiency caused by crawling webpages irrelevant to the topic in the traditional method, and improves the crawling efficiency of webpages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a TextCNN-based topic crawler method and system, which can be applied to the crawling process of a network data topic crawler. Background Art

[0002] In the crawler architecture, the design of the priority queue of URLs to be crawled affects the crawling efficiency of the subject crawler system. The subject crawler crawls web pages on the Internet according to the specified crawling strategy based on the subject specified by the user. The web links obtained by the crawler are mixed with irrelevant web links, which has a certain impact on the crawling efficiency and resources. In the subject crawler system, the queue of URLs to be crawled is a very important part. The way in which the URLs in the queue of URLs to be crawled are distributed and the order in which they are crawled is also a very important issue currently under research. How to provide an efficient and accurate crawler system and method that focuses on a specified topic and tries to avoid downloading irrelevant web pages is a problem that technicians in this field urgently need to solve.

[0003] At present, there are still many areas that can be optimized in the application process of the theme crawler system:

[0004] For search and crawling strategies based on web page structure, at present, the depth-first traversal strategy is a more popular crawler search strategy compared to the breadth-first traversal strategy. The depth-first traversal strategy is a method of distributing URL priority queue seeds. Its idea is to add the URLs obtained from the web page to the end of the URL priority queue in the order of crawling the web pages according to the depth-first idea. The URL priority queue seeds are distributed according to the first-in-last-out order, and the URL is taken out from the end of the queue each time. However, the disadvantage of this crawling strategy is that it does not take into account the importance of different pages, and will crawl irrelevant web pages, which not only wastes crawling resources, but also reduces crawling efficiency.

[0005] There are mainly Fish Search and SharkSearch for text content-based search and crawling strategies. Compared with structural search and crawling strategies, text content-based search and crawling strategies take into account the text information in web page text, such as anchor text and document keywords, and use these features to evaluate the seed URL. However, web pages are different from ordinary texts. They have web page structure features, that is, web pages do not exist in isolation, but have upper and lower link relationships. Summary of the invention

[0006] The purpose of this application is to provide a topic crawler method and system based on TextCNN to overcome the problem of low crawling efficiency caused by crawling web pages unrelated to the topic in traditional methods, thereby improving the crawling efficiency of web pages.

[0007] In order to achieve the above tasks, this application adopts the following technical solutions:

[0008] According to a first aspect of the present application, a topic crawler method based on TextCNN is provided, comprising:

[0009] Initiate a request to the target URL web page to download the web page and return the downloaded html page;

[0010] Receive the downloaded HTML page and perform HTML parsing;

[0011] Stores the time ID, URL link, URL parent link, URL anchor text, web page title and body text of the web page after HTML parsing; also stores metadata consisting of URL and URL score value;

[0012] After completing HTML parsing of all URLs, the trained scorer model is first used to score the topic relevance and store the URLs and URL scores, and then the URL seeds are distributed according to the scoring results; wherein the scorer model is a convolutional neural network composed of an input layer, a convolutional layer, a pooling layer, a fully connected layer and an output layer.

[0013] Furthermore, in the scorer model, the input value of the input layer is the anchor text feature vector of the web page feature:

[0014] For the parsed HTML page, extract the URL of the current web page, the URL of the previous web page, the anchor text of the URL, and the title of the URL as feature words;

[0015] For the anchor text and title of the URL in the feature words, the following preprocessing process is performed:

[0016] Chinese word segmentation: perform Chinese word segmentation on the URL anchor text and URL title in the feature words;

[0017] Stop word removal and text filling: Remove stop words without semantic meaning from the feature words obtained after Chinese word segmentation, and fill the deleted stop words with spaces; the feature words processed in this step are used together with the URL of the current web page and the URL of the previous web page as web page features;

[0018] Vector space representation: Vectorize the web page features to obtain the anchor text feature vector.

[0019] Furthermore, in the scorer model:

[0020] The input value of the input layer is the anchor text feature vector of the web page feature;

[0021] The convolution layer is used to extract the anchor text feature vector. The convolution layer is designed with 6*4 convolution kernels, and uses the filter window size (2, 3, 4, 5, 6, 7) words as the size of the convolution kernel. The shapes of the vectors after convolution in this layer are 198*1, 197*1, 196*1, 195*1, 194*1, and 193*1 respectively.

[0022] The pooling layer uses the maximum pooling method to reduce the text dimension and unify the features extracted by the convolution layer;

[0023] The fully connected layer is used to concatenate the feature vectors output by the pooling layer and then submit them to the output layer;

[0024] The output layer is used to classify the concatenated feature vectors, using cross entropy as the loss function; when using cross entropy, its category index 0 or 1 is directly used.

[0025] Furthermore, the HTML parsing includes: using the Python language package BeautifulSoup to convert the Html text into a node tree data structure, and then performing data cleaning to remove JavaScript scripts, missing HTML tags, character encodings and web page advertisements; and finally extracting the Anchor text in tags, web pages <title>The page title and< / title> <href>The attribute node value is URL, and the content of the web page is extracted.

[0026] Furthermore, the stored metadata is stored without duplication; when the metadata is stored for the first time, it needs to be initialized to store the root URL; the root URL is set to the homepage URL of the target website.

[0027] Furthermore, URL seeds are distributed according to URL scores, and URL seeds with high scores are distributed first.

[0028] A topic crawler system based on TextCNN, including:

[0029] Downloader, used to initiate a request to the target URL web page to download the web page and return the downloaded html page;

[0030] Parser, used to receive the downloaded HTML page and perform HTML parsing;

[0031] The access device includes a web page text content storage device and a seed storage device; wherein the web page text content storage device is used to store the time ID, URL link, URL previous link, URL anchor text, web page title and body text of the web page after HTML parsing; the seed storage device is a Redis database, which is used to store metadata consisting of URL and URL score value;

[0032] The scorer module is used to use the trained scorer model to score the topic relevance after completing HTML parsing of all URLs, and store the URLs and URL scores in the seed storage; the seed storage distributes URL seeds according to the scoring results; wherein the scorer model is a convolutional neural network composed of an input layer, a convolutional layer, a pooling layer, a fully connected layer and an output layer.

[0033] A URL seed distribution method, comprising:

[0034] Step 1: Enter one or more starting web page root URL links, and the downloader sends a network request to download and return the HTML page;

[0035] Step 2, determine whether the queue to be crawled in the seed storage is empty or whether the user stops the execution, if so, end the crawling, otherwise, execute step 3;

[0036] Step 3: Take the URL from the head of the queue to be crawled according to the priority queue order of the score value;

[0037] Step 4, sending an HTTP request to the webpage address pointed to by the retrieved URL to crawl the webpage content and parse the webpage to obtain webpage features such as the webpage URL, parent webpage URL and URL anchor text, and webpage title;

[0038] Step 5: Construct feature vectors from web page features and put them into the above scorer model for URL scoring;

[0039] Step 6: Use the URL and URL score as metadata and add them to the queue to be crawled in the seed storage according to the score; the queue is sorted according to the score.

[0040] In a third aspect, the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the TextCNN-based topic crawler method of the aforementioned first aspect are implemented.

[0041] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the TextCNN-based topic crawler method of the first aspect are implemented.

[0042] Compared with the prior art, this application has the following technical features:

[0043] 1. High accuracy. This topic crawler crawls highly relevant web pages based on text content analysis. The accuracy of web page crawling depends on the results of model training. This application is integrated with the latest TextCNN deep learning text analysis, which greatly improves the accuracy of web page crawling.

[0044] 2. High efficiency. Compared with the traditional topic crawler system, we have added a scorer model. This model not only takes into account the structural characteristics of the web page, but also combines the text content of the web page. It can reduce the crawling of URL links that are not related to the topic and improve the efficiency of the topic crawler.

[0045] 3. Easy to expand. Compared with the traditional TextCNN model, our model can adapt to the multi-dimensional features of web pages. At present, we only consider two web page structure features and two text content features. But the model we proposed is very easy to expand. According to different needs, you can add custom features, such as keywords in the document, article abstracts, the number of web page hyperlinks, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] < / href> Figure 1 This is a flowchart of the TextCNN-based topic crawler method of this application;

[0047] Figure 2 This is a network architecture diagram of the scorer model in this application;

[0048] Figure 3 Flowchart for quantizing web page text features;

[0049] Figure 4 This is the flow chart of URL seed distributor of the theme crawler system;

[0050] Figure 5 This is a schematic diagram of the structure of the theme crawler system;

[0051] Figure 6 A schematic diagram of the structure of the terminal device. DETAILED DESCRIPTION

[0052] The technical solutions in the embodiments of the present application will be clearly described below in conjunction with the drawings in the embodiments of the present application. It is obvious that the implementation described is only a part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0053] The present application provides a method and system for a topic crawler based on TextCNN. Before URL distribution, the TextCNN text analysis method is used to simultaneously consider the text content and structural features of a web page for different needs, train a seed scorer, and score the topic relevance. URL seeds are distributed according to the priority queue of the score value for topic crawler crawling. This can largely overcome the problem of low crawling efficiency caused by crawling web pages unrelated to the topic in traditional methods, and greatly improve the crawling efficiency of web pages.

[0054] The first aspect of the present application provides a topic crawler method based on TextCNN, comprising the following steps:

[0055] S1, initiate a request to the target URL web page to download the web page, and return the downloaded HTML page; when downloading the web page, set the maximum timeout connection time, for example, 60s.

[0056] S2, receiving the downloaded HTML page and performing HTML parsing; wherein HTML parsing includes: using the Python language package BeautifulSoup to convert the Html text into a node tree data structure, and then performing data cleaning to remove JavaScript scripts, missing HTML tags, character encodings and web page advertisements; finally extracting the Anchor text in tags, web pages <title> The page title and< / title> <href>The URL of the attribute node value and extract the web page content Content.

[0057] S3 stores the time ID, URL link, URL's upper-level link, URL anchor text, web page title, and body of the web page after HTML parsing; at the same time, it stores the metadata composed of the URL and the URL score value; for the stored metadata, non-duplicate storage is adopted; when storing the metadata for the first time, initialization is required to store the root URL; the root URL is generally set as the home page URL of the target website.

[0058] S4, after completing the HTML parsing of all URLs, first use the trained scoring model to perform topic relevance scoring and store the URL and the URL score, and then distribute the URL seeds according to the scoring results; specifically, the URL seeds are distributed according to the URL score, and the URL seeds with higher scores are given priority.

[0059] Using the scoring model can effectively improve the crawling efficiency of traditional topic crawlers. The scoring model performs topic relevance scoring in two stages: the feature word extraction stage and the scoring stage of the scoring model.

[0060] 4.1 The feature word extraction stage includes:

[0061] For the parsed HTML page, extract the URL of the current web page, the URL of the upper-level web page (parent web page), the anchor text of the URL, and the title of the URL as feature words.

[0062] For the anchor text of the URL and the title of the URL in the feature words, perform the following preprocessing process:

[0063] Chinese word segmentation: Use the Python language package jieba to perform Chinese word segmentation on the anchor text of the URL and the title of the URL in the feature words.

[0064] Stop word removal and text filling: Remove the stop words without semantic meaning in the feature words obtained after Chinese word segmentation, such as "de", "di", "de", etc., and fill the removed stop words with spaces; the feature words processed in this step, together with the URL of the current web page and the URL of the upper-level web page, are used as the web page features.

[0065] Vector space representation: Use the word2vec vector representation method to vectorize the web page features to obtain the anchor text feature vector; this anchor text feature vector will be used as the input value of the scoring model. Specifically, for the anchor text of the URL, the title of the URL, the URL of the current web page, and the URL of the upper-level web page, use word2vec vectorization. If the length of each feature is less than max_length, it is padded with 0, and finally all the feature vectors are concatenated together.

[0066] 4.2 Scoring stage

[0067] The scorer model in this solution adopts the TextCNN scorer model, whose network structure includes:

[0068] Input layer: The input value of the input layer is the anchor text feature vector of the web page feature. The anchor text feature vector is represented as an n*k matrix, where n is the number of words in the anchor text and k is the embedding word vector dimension corresponding to each word. In this embodiment, word2vec is used to vectorize the feature words. Here, each word will be represented by a 300-dimensional vector, so k=300, and the words that are less than max_length in the sentence are represented by 0. Therefore, the feature word will be represented as an anchor text feature vector of max_length*300. The URL of the current web page, the URL of the previous web page, the anchor text of the URL, and the title of the URL are processed in the same way. Finally, a feature obtained by splicing the four feature vectors is input. Here, it should be emphasized that the traditional TextCNN model only considers one dimension of text; in this solution, combined with web page features, multiple features such as URL, parent web page URL, and title of the web page are considered. It is worth noting that the structural hierarchical features of the web page are hidden in the URL information; in addition, the text information of the URL title is also a very useful information supplement to the anchor text of the URL. Therefore, the selection of features such as the URL of the current web page, the URL of the previous web page, the anchor text of the URL, the title of the URL, etc. all have good discrimination for the subject classification of the current web page.

[0069] Convolution layer C1: The convolution layer is used to extract the anchor text feature vector. This convolution layer is designed with 24 (6*4) convolution kernels, and uses filter window size (2, 3, 4, 5, 6, 7) words as the size of the convolution kernel. Therefore, the shape of the vector after convolution (sentence length-filter window size+1) is 198*1, 197*1, 196*1, 195*1, 194*1, 193*1 respectively. The reason for considering multiple filter window sizes here is that different convolution kernels can capture the connection of words in different ranges. The principle is similar to n-gram. For example, two words may be one feature, and three words may be another feature. For each size (2, 3, 4, 5, 6, 7) of the filter, 24 convolution kernels are used for convolution to learn the complementary features of words from the same window.

[0070] Pooling layer S1: The pooling layer is used to reduce the text dimension and unify the features extracted by the convolution layer; in the pooling layer, refer to several common pooling operations, such as mean pooling, maximum pooling, etc. Maximum pooling is used here. Because maximum pooling can better extract web page text features in the neighborhood and extract texture information. The role of adding a pooling layer to this architecture is to better reduce the text dimension, and the pooling operation can unify the features in the text feature map obtained after the convolution layer.

[0071] Fully connected layer: The fully connected layer is used to concatenate the feature vectors output by the pooling layer and then submit them to the output layer.

[0072] Output layer: The output layer is used to classify the concatenated feature vector output by the fully connected layer, using cross entropy as the loss function. Because the loss function includes the calculation of Log(SoftMax), the output of the fully connected layer of the network can be directly handed over to the cross entropy loss function for calculation. In addition, it is worth noting that when using cross entropy, the target is not a one-hot vector, but needs to directly use its category index 0 or 1.

[0073] 4.3 Training of the Scorer Model

[0074] (1) Sample collection

[0075] After building the scorer model, sample collection is required. First, this solution needs to determine the positive and negative samples of the data set so that the model can perform reasonable and effective classification; in the classification task of this solution, it is necessary to identify which are thematic websites. Here, we take news websites as an example. This solution can manually mark the data set by using URL-pattern, and a total of millions of URLs have been marked. The marking rules are as follows:

[0076] URLs that meet the following rules are marked as news pages, and the label field is copied to 1:

[0077] Contains characters such as "article-", "detail", "doc-", "docid", "blog_", and "weibook".

[0078] URLs that meet the following rules are marked as non-news web pages, and the label field is copied to 0:

[0079] Domain names with a length of less than 3, i.e. first-level and second-level pages; containing characters such as "login", "product_id", "wanwan", "weather", "game", etc.

[0080] (2) Model parameter setting

[0081] In this embodiment, pytorch is used as a practical case of this solution. In this case, the parameters of the scorer model are set as follows:

[0082] Model parameters:

[0083] filter_sizes:2,3,4,5,6,7

[0084] input_channel:1

[0085] num_filters:128, the number of filters for each filter size

[0086] dropout_keep_prob: 0.5, the probability of randomly dropping / discarding neuron parameters

[0087] l2_reg_lambda:0.0, L2 regularization lambda (default: 0.0)

[0088] Training parameters:

[0089] Batch size:512, batch size

[0090] epochs:100, training epochs

[0091] learning rate, 0.01.

[0092] (3) Training process

[0093] In the training model, a small batch dataset is used for training, and BCELoss is used to measure the binary cross entropy between the target and the output. Specifically, the loss function can be expressed as:

[0094] l(x,y)=L={l1,…,l N }

[0095] in,

[0096] l n =-w n [y n *logx n +(1-y n )*log(1-x n )]

[0097] Here N is the batch size, x n is the output of the scorer model, y n is the actual value, w n Represents weight.

[0098] In the training model, each time the data is loaded for training, the order of the data is first shuffled, and then the data set is divided according to the ratio of 9:1 between the training set and the test set; the order of the data is shuffled to ensure the randomness of the data. In order to prevent overfitting problems and test the generalization ability of the trained classifier model, this solution needs to divide the data set; this solution uses the leave-one-out method to split the data set.

[0099] In order to test the scorer model of this solution, it can be regarded as a classification problem, and the URLs related to the topic can be regarded as the positive class; there are two main performance evaluation indicators for the classification algorithm: recall rate and precision rate. Recall rate refers to the ratio of the number of crawled web pages related to the news category to all the web pages related to the news category on the Internet. Its calculation formula is:

[0100] Recall=(D / S)*100

[0101] Where D represents the downloaded news-related web pages; S represents all news-related web pages on the Internet.

[0102] The accuracy rate refers to the ratio of the news-related pages crawled by the crawler to the total number of web pages crawled by the crawler. The calculation formula is similar to the above formula. Correspondingly, D represents the news-related web pages that have been downloaded, and S represents the total number of downloaded pages.

[0103] Since it is difficult to estimate how many news-related web pages exist on the Internet, it is difficult to use recall rate to evaluate the performance of the scorer. This scheme proposes two measurement indicators based on the crawling accuracy of the topic crawler.

[0104] Metric 1: Use custom URL tagging rules to identify the number of news web pages, and count the ratio of the number of news web pages crawled before and after to the total number of web pages. The larger the ratio, the better the effect.

[0105] Metric 2: Count the number of texts on a page / the number of links on the page. Generally speaking, news pages have more texts than ordinary web pages, but fewer links. The larger the number of texts / the number of links on a page, the more likely it is that the page is a news page.

[0106] In order to optimize this application, after the model is trained, it is saved so that it can be added to the scheduler of the theme crawler. There are two forms of model preservation. One is to save the neural network and the corresponding parameters. This method will take up a large storage space. The other is to only save the parameters of the neural network. This method requires the network to be defined before the model is loaded. Here, this application recommends saving only the parameters of the neural network. Then define the network in the theme crawler system and load the model.

[0107] According to the second aspect of the present application, a topic crawler system 1 based on TextCNN is provided, such as< / href> Figure 5 As shown, including:

[0108] The downloader 11 is used to initiate a request to a target URL web page to download the web page and return the downloaded HTML page; when downloading the web page, a maximum timeout connection time is set, for example, 60 seconds.

[0109] Parser 12 is used to receive the downloaded HTML page and perform HTML parsing; wherein HTML parsing includes: using the Python language package BeautifulSoup to convert the Html text into a node tree data structure, and then performing data cleaning to remove JavaScript scripts, missing HTML tags, character encodings and web page advertisements; and finally extracting the HTML content in the web page. Anchor text in tags, web pages <title> The page title and< / title> <href>The attribute node value is URL, and the content of the web page is extracted.

[0110] The access device 13 includes a web page text content storage device and a seed storage device; wherein the web page text content storage device is used to store the time ID, URL link, URL upper link, URL anchor text, web page title and text of the web page after HTML parsing; the seed storage device is a Redis database, which is used to store metadata consisting of URL and URL score value; for the stored metadata, non-repetitive storage is adopted; the seed storage device needs to be initialized during the first crawl to store the root URL; the root URL is generally set to the homepage URL of the target website.

[0111] The scorer module 14 is used to use the trained scorer model to score the topic relevance after completing HTML parsing of all URLs, and store the URLs and URL scores in a seed storage; the seed storage distributes URL seeds according to the scoring results; wherein the scorer model is a convolutional neural network composed of an input layer, a convolutional layer, a pooling layer, a fully connected layer and an output layer.

[0112] For the corresponding implementation steps in the above-mentioned downloader, parser, memory and scorer modules, please refer to S1 to S4 of the above-mentioned method embodiment, which will not be repeated here.

[0113] Based on the above crawler system, the process of URL seed distribution includes:

[0114] Step 1: Enter one or more starting web page root URL links, and the downloader sends a network request to download and return the HTML page;

[0115] Step 2, determine whether the queue to be crawled in the seed storage is empty or whether the user stops the execution, if so, end the crawling, otherwise, execute step 3;

[0116] Step 3: Take the URL from the head of the queue to be crawled according to the priority queue order of the score value;

[0117] Step 4, sending an HTTP request to the webpage address pointed to by the retrieved URL to crawl the webpage content and parse the webpage to obtain webpage features such as the webpage URL, parent webpage URL and URL anchor text, and webpage title;

[0118] Step 5: Construct feature vectors from web page features and put them into the above scorer model for URL scoring;

[0119] Step 6: Use the URL and URL score as metadata and add them to the queue to be crawled in the seed storage according to the score; the queue is sorted according to the score.

[0120] In this step, the filtering value is not set directly for the URL score value. If the URL is directly filtered, it may cause the web crawler space tunnel problem. The best way to deal with this is to add a monitor. If a URL with no URL score value is added to the seed storage for a long time, a reminder will be issued to replace the seed in time.

[0121] See also< / href> Figure 6 The embodiment of the present application further provides a terminal device 2, which can be a computer or a server; it includes a memory 22, a processor 21, and a computer program 23 stored in the memory 22 and executable on the processor. When the processor 21 executes the computer program 23, the steps of the above-mentioned TextCNN-based topic crawler method are implemented, for example, the aforementioned S1 to S4.

[0122] The computer program 23 may also be divided into one or more modules / units, one or more modules / units are stored in the memory 22 and executed by the processor 21 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 23 in the terminal device 2. For example, the computer program 23 may be divided into a downloader, a parser, a memory, and a scorer module. The functions of each module refer to the description in the aforementioned system and will not be repeated here.

[0123] The implementation of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned TextCNN-based topic crawler method are implemented, for example, the aforementioned S1 to S4.

[0124] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0125] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A topic crawler method based on TextCNN, characterized in that: include: Initiate a request to the target URL web page to download the web page and return the downloaded html page; Receive the downloaded HTML page and perform HTML parsing; Store the time ID, URL link, URL parent link, URL anchor text, web page title and body text of the web page after HTML parsing; Stores metadata consisting of URLs and URL rating values ​​at the same time; After completing HTML parsing of all URLs, the trained scorer model is first used to score the topic relevance and store the URLs and URL scores, and then the URL seeds are distributed according to the scoring results; wherein the scorer model is a convolutional neural network composed of an input layer, a convolutional layer, a pooling layer, a fully connected layer, and an output layer; In the scorer model, the input value of the input layer is the anchor text feature vector of the web page feature: For the parsed HTML page, extract the URL of the current web page, the URL of the previous web page, the anchor text of the URL, and the title of the URL as feature words; For the anchor text and title of the URL in the feature words, the following preprocessing process is performed: Chinese word segmentation: perform Chinese word segmentation on the URL anchor text and URL title in the feature words; Stop word removal and text filling: Remove stop words without semantic meaning from the feature words obtained after Chinese word segmentation, and fill the deleted stop words with spaces; the feature words processed in this step are used together with the URL of the current web page and the URL of the previous web page as web page features; Vector space representation: vectorize the web page features to obtain the anchor text feature vector; In the scorer model: The input value of the input layer is the anchor text feature vector of the web page feature; The convolution layer is used to extract the anchor text feature vector. The convolution layer is designed with 6*4 convolution kernels, and uses the filter window size (2, 3, 4, 5, 6, 7) words as the size of the convolution kernel. The shapes of the vectors after convolution in this layer are 198*1, 197*1, 196*1, 195*1, 194*1, and 193*1 respectively. The pooling layer uses the maximum pooling method to reduce the text dimension and unify the features extracted by the convolution layer; The fully connected layer is used to concatenate the feature vectors output by the pooling layer and then submit them to the output layer; The output layer is used to classify the concatenated feature vectors, using cross entropy as the loss function; when using cross entropy, its category index 0 or 1 is directly used.

2. The TextCNN-based topic crawler method according to claim 1, characterized in that: The HTML parsing includes: using the Python language package BeautifulSoup to convert the Html text into a node tree data structure, then performing data cleaning to remove JavaScript scripts, missing HTML tags, character encodings and web page advertisements; and finally extracting the Anchor text in tags, web pages <title> The page title and< / title> <href> The attribute node value is URL, and the content of the web page is extracted.< / href> 3. The TextCNN-based topic crawler method according to claim 1, characterized in that: The stored metadata is stored without duplication. When the metadata is stored for the first time, it needs to be initialized to store the root URL. The root URL is set to the homepage URL of the target website.

4. The TextCNN-based topic crawler method according to claim 1, characterized in that: URL seeds are distributed according to the URL scores, and URL seeds with high scores are distributed first.

5. A topic crawler system based on TextCNN, characterized in that: include: Downloader, used to initiate a request to the target URL web page to download the web page and return the downloaded html page; Parser, used to receive the downloaded HTML page and perform HTML parsing; The access device includes a web page text content storage device and a seed storage device; wherein the web page text content storage device is used to store the time ID, URL link, URL previous link, URL anchor text, web page title and body text of the web page after HTML parsing; the seed storage device is a Redis database, which is used to store metadata consisting of URL and URL score value; The scorer module is used to score the topic relevance using the trained scorer model after completing HTML parsing of all URLs, and store the URLs and URL scores in a seed storage; the seed storage distributes URL seeds according to the scoring results; wherein the scorer model is a convolutional neural network composed of an input layer, a convolutional layer, a pooling layer, a fully connected layer, and an output layer; In the scorer model, the input value of the input layer is the anchor text feature vector of the web page feature: For the parsed HTML page, extract the URL of the current web page, the URL of the previous web page, the anchor text of the URL, and the title of the URL as feature words; For the anchor text and title of the URL in the feature words, the following preprocessing process is performed: Chinese word segmentation: perform Chinese word segmentation on the URL anchor text and URL title in the feature words; Stop word removal and text filling: Remove stop words without semantic meaning from the feature words obtained after Chinese word segmentation, and fill the deleted stop words with spaces; the feature words processed in this step are used together with the URL of the current web page and the URL of the previous web page as web page features; Vector space representation: vectorize the web page features to obtain the anchor text feature vector; In the scorer model: The input value of the input layer is the anchor text feature vector of the web page feature; The convolution layer is used to extract the anchor text feature vector. The convolution layer is designed with 6*4 convolution kernels, and uses the filter window size (2, 3, 4, 5, 6, 7) words as the size of the convolution kernel. The shapes of the vectors after convolution in this layer are 198*1, 197*1, 196*1, 195*1, 194*1, and 193*1 respectively. The pooling layer uses the maximum pooling method to reduce the text dimension and unify the features extracted by the convolution layer; The fully connected layer is used to concatenate the feature vectors output by the pooling layer and then submit them to the output layer; The output layer is used to classify the concatenated feature vectors, using cross entropy as the loss function; when using cross entropy, its category index 0 or 1 is directly used.

6. A method for distributing URL seeds using the system according to claim 5, characterized in that: include: Step 1: Enter one or more starting web page root URL links, and the downloader sends a network request to download and return the HTML page; Step 2, determine whether the queue to be crawled in the seed storage is empty or whether the user stops the execution, if so, end the crawling, otherwise, execute step 3; Step 3: Take the URL from the head of the queue to be crawled according to the priority queue order of the score value; Step 4, sending an HTTP request to the webpage address pointed to by the retrieved URL to crawl the webpage content and parse the webpage to obtain webpage features such as the webpage URL, parent webpage URL and URL anchor text, and webpage title; Step 5: Construct feature vectors from web page features and put them into the above scorer model for URL scoring; Step 6: Use the URL and URL score as metadata and add them to the queue to be crawled in the seed storage according to the score. The queues are sorted according to the scores.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.