Anthropomorphic crawler method based on fatigue simulation model
Through the anthropomorphic crawler method based on the fatigue simulation model, the LSTM neural network is used to simulate human access behavior and generate random sleep intervals, which solves the problem of low efficiency of existing web crawlers, achieves efficient crawling and reduces the probability of banning.
Patent Information
- Application Number
- CN202210180955.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2024-10-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing web crawler methods have deficiencies in crawling efficiency, especially when using unified rest intervals or changing IP/IP pool methods, resulting in a decrease in crawling efficiency.
The anthropomorphic crawler method based on the fatigue simulation model is used, and the LSTM neural network model is used to fit the mouse click time interval when humans visit the website, generate random sleep time intervals, and combine the crawler program to simulate human behavior for crawling.
It improves the efficiency of crawlers, reduces regularity, reduces the probability of being banned, and realizes an anthropomorphic crawling method.
Smart Images

Figure CN114547418B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information acquisition. Background Art
[0002] With the progress of society and the rapid development of the Internet, more data tends to be digitized. However, how to obtain this data has become a hot topic for scholars. The previous manual method of searching one by one is obviously no longer sufficient, with low efficiency and long time consumption. The emergence of web crawlers has changed this situation. According to different needs for data and different application occasions, web crawlers are also classified, such as general web crawlers and subject web crawlers. Traditional web crawlers start from one or several starting URLs, obtain the URL of the initial web page, and continuously put new URLs into the URL queue during the process of crawling the web page, and repeat the whole process until the crawler termination conditions are met.
[0003] There are two methods currently used. One is to use a unified rest interval; the other is to change the IP or use an IP pool. Both methods will reduce the crawling efficiency of the crawler, so the above problems need to be solved urgently. Summary of the invention
[0004] The purpose of the present invention is to solve the problem of low crawling efficiency of existing crawling methods. The present invention provides an anthropomorphic crawling method based on a fatigue simulation model. The present invention is implemented under the conditions permitted by law and without hindering the public interest.
[0005] The anthropomorphic crawler method based on the fatigue simulation model includes the following steps:
[0006] S1. Using m individuals to collect n target articles from any target website in sequence to obtain an initial data set; the initial data set is composed of m×n groups of time interval sequences obtained by all individuals collecting all target articles; m and n are both integers;
[0007] S2, preprocessing the initial data set to obtain a preprocessed data set;
[0008] S3, constructing a fatigue simulation model; the fatigue simulation model is implemented using an LSTM neural network model;
[0009] S4, dividing the preprocessed data set into two parts, one part as a training set and the other part as a validation set; using the training set to train the fatigue simulation model, so that the fatigue simulation model performs deep learning on the training set to obtain a trained fatigue simulation model;
[0010] S5. After obtaining the sleep time interval required for the current crawler task using the validation set and the trained fatigue simulation model, the sleep time interval is integrated with the crawler program to obtain the integrated crawler program, and then the integrated crawler program is used to crawl the network, thereby realizing an anthropomorphic crawler.
[0011] The beneficial effects brought by the present invention are:
[0012] The present invention uses a fatigue simulation model to fit the time interval of a mouse click when a human visits a website. When a crawler crawls the target website data, the sleep time is set based on the fitted time interval of a mouse click when a human visits the website. The trained fatigue simulation model can randomly generate the sleep time interval required for the current crawler task, reduce regularity, and realize crawling in an anthropomorphic manner. In the present invention, anthropomorphizing the crawler using a fatigue simulation model can ensure the efficiency of the crawler crawling the target website. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 is a flow chart of the anthropomorphic crawler method based on the fatigue simulation model of the present invention;
[0014] Figure 2 is a flowchart for obtaining the initial data set. DETAILED DESCRIPTION
[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0016] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0017] Specific implementation method 1: The following is combined Figure 1 The present embodiment is described. The anthropomorphic crawler method based on the fatigue simulation model described in the present embodiment comprises the following steps:
[0018] S1. Using m individuals to collect n target articles from any target website in sequence to obtain an initial data set; the initial data set is composed of m×n groups of time interval sequences obtained by all individuals collecting all target articles; m and n are both integers;
[0019] S2, preprocessing the initial data set to obtain a preprocessed data set;
[0020] S3, constructing a fatigue simulation model; the fatigue simulation model is implemented using an LSTM neural network model;
[0021] S4, dividing the preprocessed data set into two parts, one part as a training set and the other part as a validation set; using the training set to train the fatigue simulation model, so that the fatigue simulation model performs deep learning on the training set to obtain a trained fatigue simulation model;
[0022] S5. After obtaining the sleep time interval required for the current crawler task using the validation set and the trained fatigue simulation model, the sleep time interval is integrated with the crawler program to obtain the integrated crawler program, and then the integrated crawler program is used to crawl the network, thereby realizing an anthropomorphic crawler.
[0023] In this embodiment, the present invention uses a fatigue simulation model to fit the time interval of a mouse click when a human visits a website. When the crawler crawls the target website data, the sleep time is set based on the fitted time interval of a mouse click when a human visits the website. The trained fatigue simulation model can randomly generate the sleep time interval required for the current crawler task, reduce regularity, and realize crawling in an anthropomorphic manner. In the present invention, anthropomorphizing the crawler using a fatigue simulation model can ensure the efficiency of the crawler crawling the target website.
[0024] The fatigue simulation model is implemented using an LSTM neural network model. The LSTM neural network model is an existing technology, and its training process can be implemented using existing technology. Specifically, multiple groups of temporally continuous time interval sequences in the initial data set can be used as inputs to the fatigue simulation model. The fatigue simulation model continuously performs deep learning on the input multiple groups of time interval sequences, thereby predicting the time interval sequence for executing the next target task. The predicted time interval sequence is compared with the actual time interval sequence in the initial data set until the fatigue simulation model converges and the training is completed.
[0025] The crawler program is prior art.
[0026] Specific implementation method 2: The following is combined Figure 2 This embodiment further illustrates the first embodiment. In step S1, m individuals are used to collect n target articles from any target website in sequence to obtain the initial data set in the following manner:
[0027] Step S11, entering any target website;
[0028] Step S12: Use m individuals to click on the i-th target article on the same target website, and record the click time t of each individual pi1 , the initial value of i is 1; among them,
[0029] t pi1 is the time when the Pth individual clicks on the i-th target article;
[0030] P and i are both integers, and i = 1, 2, 3, ..., n, P = 1, 2, 3, ..., m;
[0031] Step S13: m individuals select the attribute of the i-th target article to be downloaded, and click to select the attribute, while recording the click time t of each individual. pi2 , the target article attribute is PDF or word; wherein,
[0032] t pi2 The time it takes for the Pth individual to click and select the attribute of the i-th target article;
[0033] Step S14: m individuals click to download according to the attributes of the selected i-th target article, and record the click time t of each individual. pi3 ;
[0034] t pi3 The time it takes for the Pth individual to click and download the target article with the selected attribute after selecting the attribute of the i-th target article;
[0035] Step S15: Each individual clicks to return to the previous directory, returns to the target website, and records the click time t of each individual when performing this operation. pi4 ;
[0036] t pi4 The click time when the Pth individual clicks to download the i-th target article and then returns to the previous directory;
[0037] Step S16: According to t pi1 ,t pi2 ,t pi3 and t pi4 , obtain the time interval sequence S of each individual's collection operation on the i-th target article Pi ={t pi2 -t pi1 , t pi3 -t pi2 , t pi4 -t pi3},in,
[0038] S Pi A set of time interval sequences obtained by the P-th individual collecting the i-th target article;
[0039] Step S17, set i=i+1, and return to step S12 until m×n groups of time interval sequences are obtained by all individuals performing collection operations on all articles, and the m×n groups of time interval sequences obtained by all individuals performing collection operations on all target articles constitute the initial data set.
[0040] In this preferred implementation manner, the constructed initial data set is a data set obtained by actually executing a task, thereby ensuring the authenticity of the data set.
[0041] Specific implementation method three: the following combination Figure 1 This embodiment further describes the first embodiment. In step S2, the initial data set is preprocessed to obtain the preprocessed data set in the following manner:
[0042] The outlier algorithm is used to remove the outlier time interval sequence in the initial data set to obtain the preprocessed data set.
[0043] Specific implementation method 4: The following is combined Figure 1 This embodiment further illustrates the first embodiment. In step S5, the sleep time interval required for the current crawler task is obtained by using the validation set and the trained fatigue simulation model:
[0044] The trained fatigue simulation model is used to read K groups of continuous time interval sequences in the verification set in real time and randomly. The trained fatigue simulation model predicts the time interval sequence required for the current crawler task to perform the collection operation through the read K groups of time interval sequences, and outputs the time interval sequence required for the current crawler task to perform the collection operation;
[0045] Then, the time interval sequence output by the trained fatigue simulation model is used as the sleep time interval required for the current crawler task;
[0046] The crawler task is the target article to be collected, and K is an integer greater than or equal to 2.
[0047] Specific implementation method five: the following combination Figure 1 This embodiment further illustrates the first embodiment. In step S5, the specific implementation method of integrating the sleep time interval with the crawler program is as follows:
[0048] Add the sleep time interval to the crawler program to obtain the integrated crawler program.
[0049] In specific applications, the sleep time interval is added to the crawler program, so that the existing crawler program can implement intermittent crawling to simulate the process of human data acquisition and crawling, thereby ensuring the efficiency of the crawler in crawling the target website while reducing the probability of being blocked.
[0050] Specific implementation method six: the following combination Figure 1 This embodiment is described. This embodiment further describes the first embodiment. The value of K is 3.
[0051] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that features described in conjunction with individual embodiments may be used in other described embodiments.
Claims
1. An anthropomorphic crawler method based on a fatigue simulation model, characterized in that: The steps include: S1. Using m individuals to collect n target articles from any target website in sequence to obtain an initial data set; the initial data set is composed of m×n groups of time interval sequences obtained by all individuals collecting all target articles; m and n are both integers; The implementation method for obtaining the initial data set is: Step S11, entering any target website; Step S12: Use m individuals to click on the i-th target article on the same target website, and record the click time t of each individual pi1 , the initial value of i is 1; among them, t pi1 is the time when the Pth individual clicks on the i-th target article; P and i are both integers, and i = 1, 2, 3, ..., n, P = 1, 2, 3, ..., m; Step S13: m individuals select the attribute of the i-th target article to be downloaded, and click to select the attribute, while recording the click time t of each individual. pi2 , the target article attribute is PDF or word; wherein, t pi2 The time it takes for the Pth individual to click and select the attribute of the i-th target article; Step S14: m individuals click to download according to the attributes of the selected i-th target article, and record the click time t of each individual. pi3 ; t pi3 The time it takes for the Pth individual to click and download the target article with the selected attribute after selecting the attribute of the i-th target article; Step S15: Each individual clicks to return to the previous directory, returns to the target website, and records the click time t of each individual pi4 ; t pi4 The click time when the Pth individual clicks to download the i-th target article and then returns to the previous directory; Step S16: According to t pi1 ,t pi2 ,t pi3 and t pi4 , obtain the time interval sequence S of each individual's collection operation on the i-th target article Pi ={t pi2 -t pi1 , t pi3 -t pi2 , t pi4 -t pi3 },in, S Pi A set of time interval sequences obtained by the P-th individual collecting the i-th target article; Step S17, set i=i+1, and return to step S12, until all individuals perform collection operations on all articles to obtain m×n groups of time interval sequences, and the m×n groups of time interval sequences obtained by all individuals perform collection operations on all target articles to form an initial data set; S2, preprocessing the initial data set to obtain a preprocessed data set; S3, constructing a fatigue simulation model; the fatigue simulation model is implemented using an LSTM neural network model; S4, dividing the preprocessed data set into two parts, one part as a training set and the other part as a validation set; using the training set to train the fatigue simulation model, so that the fatigue simulation model performs deep learning on the training set to obtain a trained fatigue simulation model; S5. After obtaining the sleep time interval required for the current crawler task using the validation set and the trained fatigue simulation model, the sleep time interval is integrated with the crawler program to obtain the integrated crawler program, and then the integrated crawler program is used to crawl the network, thereby realizing an anthropomorphic crawler.
2. The anthropomorphic crawler method based on fatigue simulation model according to claim 1 is characterized in that: In step S2, the initial data set is preprocessed to obtain the preprocessed data set in the following manner: The outlier algorithm is used to remove the outlier time interval sequence in the initial data set to obtain the preprocessed data set.
3. The anthropomorphic crawler method based on fatigue simulation model according to claim 1 is characterized in that: In step S5, the implementation method of obtaining the sleep time interval required for the current crawler task by using the validation set and the trained fatigue simulation model is as follows: The trained fatigue simulation model is used to read K groups of continuous time interval sequences in the verification set in real time and randomly. The trained fatigue simulation model predicts the time interval sequence required for the current crawler task to perform the collection operation through the read K groups of time interval sequences, and outputs the time interval sequence required for the current crawler task to perform the collection operation; Then, the time interval sequence output by the trained fatigue simulation model is used as the sleep time interval required for the current crawler task; The crawler task is the target article to be collected, and K is an integer greater than or equal to 2.
4. The anthropomorphic crawler method based on fatigue simulation model according to claim 1 is characterized in that: In step S5, the specific implementation method of integrating the sleep time interval with the crawler program is: Add the sleep time interval to the crawler program to obtain the integrated crawler program.
5. The anthropomorphic crawler method based on fatigue simulation model according to claim 3 is characterized in that: The value of K is 3.
Citation Information
Patent Citations
Webpage crawler system and webpage crawling method
CN104933138A
Internet creeper concurrency data collection method and system based on crowd behavior simulation
CN106021552A
Microblog data acquisition method based on multi-strategy fusion
CN109933701A
Data capturing method and device
CN110020046A
Crawler self-adaptive classification method based on distributed network
CN111984848A
