CN109670101B - Crawler scheduling method and device, electronic equipment and storage medium - Google Patents
Crawler scheduling method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN109670101B CN109670101B CN201811631616.3A CN201811631616A CN109670101B CN 109670101 B CN109670101 B CN 109670101B CN 201811631616 A CN201811631616 A CN 201811631616A CN 109670101 B CN109670101 B CN 109670101B
- Authority
- CN
- China
- Prior art keywords
- crawled
- scheduling
- data parameters
- crawler
- module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a crawler scheduling method, which is applied to the technical field of computers and comprises the following steps: the method comprises the steps of obtaining data parameters of a webpage to be crawled, calculating statistics of the data parameters according to a time sequence, and calculating statistics including times, a mean value, a variance, a covariance and an autoregressive coefficient based on the statistics. And determining the scheduling time for crawling the data parameters of the webpage next time through a logistic regression algorithm and an FTRL algorithm, and updating the scheduling task queue according to the scheduling time. The invention also discloses a crawler scheduling device, electronic equipment and a storage medium, which can improve the crawling efficiency of the crawler.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a crawler scheduling method and device, electronic equipment and a storage medium.
Background
With the explosive growth of internet information, the traditional way of collecting data by web crawlers has gradually shown disadvantages. The existing crawler technology generally uses manual rules to formulate the weight of crawling a website, so that corresponding crawler resources are distributed, a regular polling mode is adopted for grabbing, and crawling efficiency is low.
Disclosure of Invention
The invention mainly aims to provide a crawler scheduling method, a crawler scheduling device, electronic equipment and a storage medium, which can improve the crawling efficiency of a crawler.
In order to achieve the above object, a first aspect of the embodiments of the present invention provides a crawler scheduling method, including:
acquiring data parameters of a webpage to be crawled;
calculating statistics of the data parameters according to the time sequence, wherein the statistics comprise times, mean values, variances, covariances and autoregressive coefficients;
determining the scheduling time of the data parameter of the next crawled webpage through a logistic regression algorithm and an FTRL algorithm based on the statistic;
and updating a scheduling task queue according to the scheduling time, wherein the scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled.
The acquiring of the data parameters of the webpage to be crawled comprises the following steps:
acquiring link address information of a website to be crawled;
and downloading the data parameters of the website to be crawled from a server according to the link address information.
The data parameters comprise any one or more items of link addresses, return codes, data sizes, content updating time, resource categories, page languages and website territories.
After the data parameters of the webpage to be crawled are obtained, the method comprises the following steps:
and storing the data parameters in a preset database.
A second aspect of an embodiment of the present invention provides a crawler scheduling apparatus, including:
the acquisition module is used for acquiring data parameters of a webpage to be crawled;
the calculation module is used for calculating the statistics of the data parameters according to the time sequence, wherein the statistics comprise times, a mean value, a variance, a covariance and an autoregressive coefficient;
the determining module is used for determining the scheduling time of the data parameter of the next crawl of the webpage through a logistic regression algorithm and an FTRL algorithm based on the statistic;
and the updating module is used for updating a scheduling task queue according to the scheduling time, wherein the scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled.
The acquisition module includes:
the acquisition submodule is used for acquiring link address information of a website to be crawled;
and the downloading module is used for downloading the data parameters of the website to be crawled from the server according to the link address information.
The data parameters comprise any one or more items of link addresses, return codes, data sizes, content updating time, resource categories, page languages and website territories.
The device further comprises:
and the storage module is used for storing the data parameters in a preset database.
A third aspect of an embodiment of the present invention provides an electronic device, including:
the crawler scheduling method is characterized in that the crawler scheduling method provided by the first aspect of the embodiment of the invention is realized when the program is executed by the processor.
A fourth aspect of the embodiments of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the crawler scheduling method provided in the first aspect of the embodiments of the present invention.
It can be known from the foregoing embodiments of the present invention that, the crawler scheduling method, apparatus, electronic device, and storage medium provided by the present invention obtain data parameters of a web page to be crawled, calculate statistics of the data parameters according to a time sequence, and based on the statistics, the statistics include times, a mean, a variance, a covariance, and an autoregressive coefficient. And determining the scheduling time for crawling the data parameters of the webpage next time through a logistic regression algorithm and an FTRL algorithm, and updating a scheduling task queue according to the scheduling time, so that the crawling efficiency of the crawler can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a crawler scheduling method according to a first embodiment of the present invention;
fig. 2 is a schematic structural diagram of a crawler scheduling apparatus according to another embodiment of the present invention;
fig. 3 shows a hardware configuration diagram of an electronic device.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a schematic flow chart of a crawler scheduling method according to a first embodiment of the present invention, where the method is applicable to an electronic device, and the electronic device includes: the method mainly comprises the following steps of:
s101, acquiring data parameters of a webpage to be crawled;
and acquiring link address information of the website to be crawled. And a link address of the website to be crawled, such as a file download link or a news list page link.
And downloading the data parameters of the website to be crawled from the server according to the link address information. Understandably, all data parameter information crawled by the crawler is stored in the server, namely a big data server. Illustratively, the server may be a kafka cluster.
The data parameters comprise any one or more items of link address, return code, data size, content update time, resource category, page language and website territory.
Further, the acquired data parameters may be stored in a preset database. Illustratively, the database may be a mongo time series database.
S102, calculating the statistic of the data parameter according to the time sequence;
the statistics include number of times, mean, variance, covariance, and autoregressive coefficients.
S103, determining the scheduling time of the data parameter of the next webpage crawling through a logistic regression algorithm and an FTRL algorithm based on the statistic;
and (3) taking the data parameters as basic characteristic data, and predicting and adjusting the scheduling time of the next crawling of each downloading resource in real time by using a logistic regression algorithm and an FTRL algorithm.
The logistic regression algorithm is a generalized linear regression analysis model, and is also called logarithmic probability regression.
The FTRL is a common optimization algorithm for online learning which is suitable for processing super-large-scale data and contains a large number of sparse features.
And S104, updating the scheduling task queue according to the scheduling time.
And the scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled, and when the scheduling time corresponding to the resources to be crawled is changed, the scheduling time is correspondingly changed in the scheduling task queue.
In the embodiment of the invention, the data parameters of the webpage to be crawled are obtained, the statistic of the data parameters is calculated according to the time sequence, and the statistic comprises times, a mean value, a variance, a covariance and an autoregressive coefficient. And determining the scheduling time for crawling the data parameters of the webpage next time through a logistic regression algorithm and an FTRL algorithm, and updating a scheduling task queue according to the scheduling time, so that the crawling efficiency of the crawler can be improved.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a crawler scheduling apparatus according to another embodiment of the present invention, which may be embedded in an electronic device, the crawler scheduling apparatus mainly includes:
an acquisition module 201, a calculation module 202, a determination module 203 and an update module 204.
The obtaining module 201 is configured to obtain data parameters of a webpage to be crawled.
Further, the obtaining module 201 includes:
the obtaining submodule is used for obtaining link address information of a website to be crawled, and link addresses of the website to be crawled, such as file downloading links or news list page links.
And the downloading module is used for downloading the data parameters of the website to be crawled from the server according to the link address information. Understandably, all data parameter information crawled by the crawler is stored in the server, namely a big data server. Illustratively, the server may be a kafka cluster.
The data parameters comprise any one or more items of link addresses, return codes, data sizes, content updating time, resource categories, page languages and website regions.
And the calculating module 202 is configured to calculate statistics of the data parameters according to the time series, where the statistics include times, mean, variance, covariance, and auto-regression coefficients.
And the determining module 203 is used for determining the scheduling time of the data parameter of the next crawl of the webpage through a logistic regression algorithm and an FTRL algorithm based on the statistic.
The logistic regression algorithm is a generalized linear regression analysis model, and is also called logarithmic probability regression.
The FTRL is a common optimization algorithm for online learning which is suitable for processing super-large-scale data and contains a large number of sparse features.
And an updating module 204, configured to update the scheduling task queue according to the scheduling time.
The scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled.
Further, the apparatus further comprises:
and the storage module is used for storing the data parameters in a preset database. Illustratively, the database may be a mongo time series database.
In the embodiment of the invention, the data parameters of the webpage to be crawled are obtained, the statistic of the data parameters is calculated according to the time sequence, and the statistic comprises times, a mean value, a variance, a covariance and an autoregressive coefficient. And determining the scheduling time for crawling the data parameters of the webpage next time through a logistic regression algorithm and an FTRL algorithm, and updating a scheduling task queue according to the scheduling time, so that the crawling efficiency of the crawler can be improved.
Referring to fig. 3, fig. 3 shows a hardware structure diagram of an electronic device.
The electronic device described in this embodiment includes:
a memory 31, a processor 32 and a computer program stored on the memory 31 and executable on the processor, the processor implementing the crawler scheduling method described in the foregoing embodiment shown in fig. 1 when executing the program.
Further, the electronic device further includes:
at least one input device 33; at least one output device 34.
The memory 31, processor 32 input device 33 and output device 34 are connected by a bus 35.
The input device 33 may be a camera, a touch panel, a physical button, or a mouse. The output device 34 may specifically be a display screen.
The Memory 31 may be a high-speed Random Access Memory (RAM) Memory or a non-volatile Memory (non-volatile Memory), such as a disk Memory. The memory 31 is used for storing a set of executable program code, and the processor 32 is coupled to the memory 31.
Further, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium may be provided in the terminal in the foregoing embodiments, and the computer-readable storage medium may be the memory in the foregoing embodiment shown in fig. 3. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the crawler scheduling method described in the foregoing embodiment shown in fig. 1. Further, the computer-readable storage medium may be various media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication link may be through some interfaces, and the indirect coupling or communication link of the modules may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present invention is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no acts or modules are necessarily required of the invention.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the above description, for a general person skilled in the art, there are variations on the specific implementation manners and application ranges according to the concepts of the embodiments of the present invention, and in summary, the contents of the present specification should not be construed as limiting the present invention.
Claims (8)
1. A crawler scheduling method, comprising:
acquiring data parameters of a webpage to be crawled; the data parameters comprise any items of link addresses, return codes, data sizes, content updating time, resource categories, page languages and website regions;
calculating statistics of the data parameters according to the time sequence, wherein the statistics comprise times, mean values, variances, covariances and autoregressive coefficients;
determining the scheduling time of the data parameter of the next crawled webpage through a logistic regression algorithm and an FTRL algorithm based on the statistic;
and updating a scheduling task queue according to the scheduling time, wherein the scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled.
2. The crawler scheduling method according to claim 1, wherein the obtaining data parameters of the web page to be crawled comprises:
acquiring link address information of a website to be crawled;
and downloading the data parameters of the website to be crawled from a server according to the link address information.
3. The crawler scheduling method according to claim 1, wherein after the obtaining of the data parameters of the web page to be crawled, the crawler scheduling method comprises:
and storing the data parameters in a preset database.
4. A crawler scheduling apparatus, comprising:
the system comprises an acquisition module, a search module and a display module, wherein the acquisition module is used for acquiring data parameters of a webpage to be crawled, and the data parameters comprise any multiple items of a link address, a return code, a data size, content updating time, a resource category, a page language and a website region;
the calculation module is used for calculating the statistics of the data parameters according to the time sequence, wherein the statistics comprise times, a mean value, a variance, a covariance and an autoregressive coefficient;
the determining module is used for determining the scheduling time of the data parameter of the next crawl of the webpage through a logistic regression algorithm and an FTRL algorithm based on the statistic;
and the updating module is used for updating a scheduling task queue according to the scheduling time, wherein the scheduling task queue comprises resources to be crawled and scheduling time corresponding to the resources to be crawled.
5. The crawler scheduling apparatus according to claim 4, wherein the obtaining module comprises:
the acquisition submodule is used for acquiring link address information of a website to be crawled;
and the downloading module is used for downloading the data parameters of the website to be crawled from the server according to the link address information.
6. The crawler scheduling apparatus according to claim 5, wherein said apparatus further comprises:
and the storage module is used for storing the data parameters in a preset database.
7. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the crawler scheduling method according to any one of claims 1 to 3 when executing the computer program.
8. A computer-readable storage medium, having a computer program stored thereon, which, when being executed by a processor, carries out the steps of the crawler scheduling method according to any one of claims 1 to 3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811631616.3A CN109670101B (en) | 2018-12-28 | 2018-12-28 | Crawler scheduling method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811631616.3A CN109670101B (en) | 2018-12-28 | 2018-12-28 | Crawler scheduling method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109670101A CN109670101A (en) | 2019-04-23 |
CN109670101B true CN109670101B (en) | 2021-01-26 |
Family
ID=66146566
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811631616.3A Active CN109670101B (en) | 2018-12-28 | 2018-12-28 | Crawler scheduling method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109670101B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110532453B (en) * | 2019-08-12 | 2022-07-22 | 北京智游网安科技有限公司 | Method for adjusting crawler updating frequency, storage medium and crawler server |
CN111444412B (en) * | 2020-04-03 | 2023-06-16 | 北京明朝万达科技股份有限公司 | Method and device for scheduling web crawler tasks |
CN111753162A (en) * | 2020-06-29 | 2020-10-09 | 平安国际智慧城市科技股份有限公司 | Data crawling method, device, server and storage medium |
CN112100472B (en) * | 2020-09-11 | 2023-11-28 | 深圳市科盾科技有限公司 | Crawler scheduling method, crawler scheduling device, terminal equipment and readable storage medium |
CN112231538B (en) * | 2020-12-15 | 2021-05-14 | 中移(苏州)软件技术有限公司 | Method, device, equipment and storage medium for updating scheduling task queue |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8196176B2 (en) * | 2007-04-18 | 2012-06-05 | Ca, Inc. | System and method for identifying a cookie as a privacy threat |
CN103176985B (en) * | 2011-12-20 | 2016-06-29 | 中国科学院计算机网络信息中心 | The most efficient a kind of internet information crawling method |
CN103176983B (en) * | 2011-12-20 | 2016-04-27 | 中国科学院计算机网络信息中心 | A kind of event method for early warning based on internet information |
CN106611005B (en) * | 2015-10-26 | 2020-04-03 | 北京国双科技有限公司 | Method and device for setting crawling time interval of crawler |
CN107590188B (en) * | 2017-08-08 | 2020-02-14 | 杭州灵皓科技有限公司 | Crawler crawling method and management system for automatic vertical subdivision field |
-
2018
- 2018-12-28 CN CN201811631616.3A patent/CN109670101B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN109670101A (en) | 2019-04-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109670101B (en) | Crawler scheduling method and device, electronic equipment and storage medium | |
CN109190049B (en) | Keyword recommendation method, system, electronic device and computer readable medium | |
CN106250464B (en) | Training method and device of ranking model | |
JP5916959B2 (en) | Dynamic data acquisition method and system | |
CN108021708B (en) | Content recommendation method and device and computer readable storage medium | |
US10095695B2 (en) | Dynamically determining the relatedness of web objects | |
CN111459993B (en) | Configuration updating method, device, equipment and storage medium based on behavior analysis | |
CN108121814B (en) | Search result ranking model generation method and device | |
CN111259220B (en) | Data acquisition method and system based on big data | |
CN103605848A (en) | Method and device for analyzing paths | |
US20120166412A1 (en) | Super-clustering for efficient information extraction | |
CN109087138A (en) | Data processing method and system, computer system and readable storage medium storing program for executing | |
CN113918794B (en) | Enterprise network public opinion benefit analysis method, system, electronic equipment and storage medium | |
CN103544271B (en) | Load Image in a kind of browser the method and apparatus for processing window | |
KR101494795B1 (en) | Method for representing document as matrix | |
CN111489196B (en) | Prediction method and device based on deep learning network, electronic equipment and medium | |
CN110990701B (en) | Book searching method, computing device and computer storage medium | |
CN111191242A (en) | Vulnerability information determination method and device, computer readable storage medium and equipment | |
CN113792232B (en) | Page feature calculation method, page feature calculation device, electronic equipment, page feature calculation medium and page feature calculation program product | |
CN102929978B (en) | Based on the drop-down prompt system of input prefix | |
CN113656737A (en) | Webpage content display method and device, electronic equipment and storage medium | |
US9002818B2 (en) | Calculating a content subset | |
CN112597760A (en) | Method and device for extracting domain words in document | |
CN112395510A (en) | Method and device for determining target user based on activity | |
CN112016017A (en) | Method and device for determining characteristic data |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Address after: 100088 Building 3 332, 102, 28 Xinjiekouwai Street, Xicheng District, Beijing Applicant after: Qianxin Technology Group Co., Ltd. Address before: 100088 Building 3 332, 102, 28 Xinjiekouwai Street, Xicheng District, Beijing Applicant before: BEIJING QI'ANXIN SCIENCE & TECHNOLOGY CO., LTD. |
|
CB02 | Change of applicant information | ||
GR01 | Patent grant | ||
GR01 | Patent grant |