WO2020019476A1 - 获取数据资源的方法和装置 - Google Patents

获取数据资源的方法和装置 Download PDF

Info

Publication number
WO2020019476A1
WO2020019476A1 PCT/CN2018/107635 CN2018107635W WO2020019476A1 WO 2020019476 A1 WO2020019476 A1 WO 2020019476A1 CN 2018107635 W CN2018107635 W CN 2018107635W WO 2020019476 A1 WO2020019476 A1 WO 2020019476A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
traffic data
extensible hypertext
interactive
hypertext transmission
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.)
Ceased
Application number
PCT/CN2018/107635
Other languages
English (en)
French (fr)
Inventor
张驰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2020019476A1 publication Critical patent/WO2020019476A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Definitions

  • the present application relates to the field of computer technology, and in particular, to a method and device for acquiring data resources.
  • the embodiments of the present application provide a method and an apparatus for acquiring data resources, and solves the problem that the process of batch downloading data is troublesome.
  • a method for acquiring data resources including:
  • An extensible hypertext transfer request (XMLHttpRequest) to a data resource update system is triggered by a web crawler, and the web crawler obtains data of the data resource update system by simulating a target, the target
  • the method is a method in which the browser requests to obtain data of the data resource update system through a hypertext transfer protocol (HTTP);
  • the traffic data corresponding to the first download destination is obtained from the interactive traffic data and saved locally.
  • an apparatus for acquiring data resources including:
  • a request triggering module is configured to trigger an extensible hypertext transmission request to a data resource update system through a web crawler, and the web crawler obtains data of the data resource update system by simulating a target mode, and the target mode is a browser via HTTP A manner for requesting data of the data resource update system;
  • a traffic intercepting module is configured to intercept the extensible hypertext transmission request and the return data corresponding to the extensible hypertext transmission request to obtain the interactive traffic data corresponding to the extensible hypertext transmission request, and the interactive traffic data Including the extensible hypertext transmission request and the returned data;
  • a saving module configured to obtain, from the interactive traffic data, traffic data corresponding to a first downloading destination and save the traffic data locally.
  • another apparatus for acquiring data resources includes a processor, a memory, and a communication interface.
  • the processor, the memory, and the communication interface are connected to each other.
  • the communication interface is used to receive or send data.
  • the memory is configured to store application program code of the apparatus for acquiring data resources to execute the foregoing method, and the processor is configured to execute the method of the first aspect.
  • a computer storage medium stores a computer program, where the computer program includes program instructions, and the program instructions, when executed by a processor, cause the processor to execute the foregoing first aspect. method.
  • This technical solution can realize batch downloading of traffic data.
  • FIG. 1 is a schematic flowchart of a website security detection method according to an embodiment of the application
  • FIG. 2 is a schematic flowchart of another method for obtaining a data resource according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of interactive traffic data provided by an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of another method for acquiring data resources according to an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a device for acquiring data resources according to an embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of another apparatus for acquiring data resources according to an embodiment of the present application.
  • the XMLHttpRequest object is the object of the XMLHttp component (component in the browser). Through this object, Ajax can only exchange data layer with the server like a desktop application, without having to refresh the interface each time and do not have to process data. They are all left to the server to do, which can reduce the server's burden, at the same time speed up the response time, and shorten the user's waiting time for the page to be displayed.
  • the XMLHttpRequest object is responsible for asynchronously communicating user information to the server and receiving server response information and data.
  • the XMLHttpRequest object can initiate an asynchronous HTTP request to the server, listen to the server status, and receive the information data returned by the server after the server completes the data response processing.
  • FIG. 1 is a schematic flowchart of a website security detection method according to an embodiment of the application. As shown in the figure, the method includes:
  • a scalable hypertext transmission request for a data resource update system is triggered by a web crawler.
  • the web crawler obtains data of the data resource update system by simulating a target mode, and the target mode is that the browser obtains the data through an HTTP request The way data sources update system data.
  • the data resource update system may be a website system that provides a data resource download service
  • the data resources may be resources such as documents, pictures, videos, and audio.
  • the web crawler can simulate the behavior of the browser, and the web crawler can implement data interaction with the server like a browser.
  • the web crawler can start from an initial URL of the data resource update system and simulate the browser and In the manner of interaction between the background servers corresponding to the data resource update system, each URL in the data resource update system is crawled in order to obtain the content of the webpage in the data update resource system.
  • the XMLHttpRequest request refers to an XMLHttpRequest object of a web crawler that simulates an asynchronous HTTP request made by the browser's XMLHttpRequest object to the server.
  • the XMLHttpRequest request triggered by the web crawler includes that the web crawler starts from a URL of the data resource update system and responds to the data resource update system during the entire process of crawling data of web pages corresponding to each URL in the website system. Every asynchronous HTTP request initiated by the background server.
  • a scalable hypertext transmission request to the data resource update system triggered by a web crawler refers to a process of simulating a real browser and a background server corresponding to the data resource update system to perform multiple asynchronous transmissions and loads.
  • the data resource update system The corresponding background server is used to manage and maintain various resources of the data resource update system, and the corresponding background server of the data resource update system is also used to provide the browser with resources of the website system.
  • the process of simulating a real browser and the background server corresponding to the data resource update system to perform multiple asynchronous transmissions and loadings can be as follows: First, create a web crawler's XMLHttpRequeset object locally and register a callback method for the XMLHttpRequeset object; Corresponding parameters of the interaction between the web crawler and the background server corresponding to the data resource update system and the data sent to the background server corresponding to the data resource update system; finally, the communication interaction between the web crawler and the background server corresponding to the data resource update system is started.
  • a series of operations on the web crawler by the user may be simulated to continuously trigger the XMLHttpRequest request to the data resource update system, which may specifically include Simulate user login, simulate clicking links on web pages, drop down web pages, etc.
  • intercepting the XMLHttpRequest request and the return data corresponding to the XMLHttpRequest request refers to intercepting the target request and target data during the asynchronous transmission and loading of the browser and the background server corresponding to the data resource update system simulated by the web crawler.
  • the target request is one or more requests that the simulated browser sends to the background server corresponding to the data resource update system.
  • the target request can be an access request, such as a request to access a page of the website system; the target request can also be a request for a parameter.
  • the target request may also be a parameter query request, a parameter modification request, etc., and is not limited to the description here.
  • the target data is the data returned by the background server corresponding to the website system according to the target request. For example, if the target request is an access request, the target data is the page data of the page corresponding to the access request; for another example, if the target request is a parameter submission request, then The target data is the data submitted in response to this parameter.
  • the XMLHttpRequest request and the return data corresponding to the XMLHttpRequest request may be intercepted by setting a proxy on the XMLHttpRequest object in a web crawler, which may specifically be:
  • the first step is to backup all methods and all attributes under the XMLHttpRequest object of the web crawler.
  • all methods under the XMLHttpRequest object include an abort () method, a getAllResponseHeaders () method, a getResponseHeader () method, an open () method, a send () method, and a setRequestHeader () method.
  • the abort () method is used to cancel the current request;
  • the getAllResponseHeaders () method is used to obtain all the HTTP header information;
  • the getResponseHeader () method is used to obtain a specified HTTP header information;
  • the open () method is used to create a HTTP request, and specify the request mode, such as get request or post request; send () method is used to send the created request to the corresponding server of the website system, and receive the corresponding response information, that is, to receive the returned data; setRequestHeader () method Used to set the HTTP header of a specified request.
  • All attributes under the XMLHttpRequest object include the readyState attribute, the Onreadysatatechage attribute, the responseText attribute, the responseXML attribute, the status attribute, and the statusText attribute.
  • the value of the readyState property is 0 to 4 and is used to indicate the progress of an interactive process.
  • the value of readyState is 0 to indicate the initialization state.
  • the XMLHttpRequest object has been created or reset by the abort () method.
  • the value of readyState is 1 to indicate The open () method has been called, but the send () method has not been called, that is, the request has not been sent; a value of readyState of 2 means that the send () method has been called, and the HTTP request has been sent to the corresponding background server of the website system , The response has not been received yet; the value of readyState is 3 to indicate that all response headers have been received, and the response has started to be received but not completed; the value of readyState indicates that the HTTP response has been completely received.
  • the responseText property is used to indicate the response data currently received by the background server. If no data has been received, the responseText property is an empty string. If readyState is less than 3, the responseText property is an empty string.
  • the responseText property is the currently received response data. If readyState is 4, the responseText property holds the complete response data.
  • the responseXML attribute is used to represent the response to the request, which is parsed into XML.
  • the status attribute is the HTTP status code returned by the background server corresponding to the website system. For example, 200 indicates that the request was successful, and 404 indicates a "Not Found” error.
  • the statusText property returns the status of the response line for the current request. It is "OK” when the status is 200, and "Not Found” when the status is 404.
  • all methods and all attributes under the XMLHttpRequest object can be saved to the global object to complete the backup of all methods and all attributes under the XMLHttpRequest object.
  • the second step is to override the XMLHttpRequest object by method rewriting to get the XMLHttpRequest object proxy corresponding to the XMLHttpRequest object.
  • the specific method of overriding the XMLHttpRequest object to obtain the XMLHttpReques object proxy corresponding to the XMLHttpRequest object through method rewriting is to create an XMLHttpRequest instance corresponding to the XMLHttpRequest object stored in the global object, traverse all the attributes and all methods of the XMLHttpRequest instance, and the XMLHttpRequest Each method of the instance generates its corresponding proxy method, and its corresponding proxy property is generated for each attribute of the XMLHttpRequest instance.
  • the third step is to intercept the XMLHttpRequest request and the returned data corresponding to the XMLHttpRequest request through the XMLHttpRequest object proxy.
  • each proxy method intercepts the XMLHttpRequest request initiated by the simulated browser, and then passes the XMLHttpRequest request so that the XMLHttpRequest request can be sent to the corresponding background server of the website system.
  • the proxy method intercepts the return data, and then releases the return data so that the return data can be transmitted to the web crawler.
  • the first download purpose may be a preset purpose or a download purpose specified by the user. Where the first download purpose is a download purpose specified by the user, a plurality of download purpose options may be displayed to the user, and the first download purpose may be determined according to the user's selection of these multiple download purposes.
  • the first download purpose is used to indicate the content or category of traffic data that needs to be downloaded in the data resource update system.
  • the first download purpose is picture download, it means that the traffic data that needs to be downloaded in the data update system is picture data; for another example, if the first download goal is video download, it means that the traffic that needs to be downloaded in the data update system
  • the data is video data; for example, if the first download purpose is document download, it means that the traffic data that needs to be downloaded in the data update system is document data; and if the first download purpose is audio download, it means that the data needs to be downloaded
  • the traffic data downloaded in the update system is audio data.
  • the first download purpose is URL download, which means that the traffic data to be downloaded in the data update system is URL data; it is not limited to the description here.
  • the traffic data that needs to be downloaded indicated by the first download purpose can be filtered, and then the filtered traffic data is saved locally.
  • the web crawler is a web crawler that obtains data of the website system in a manner that simulates a browser.
  • the web crawler can obtain data of all webpages in the data resource update system.
  • the XMLHttpRequest object of the web crawler provides Full access to the Hypertext Transfer Protocol (HTTP) protocol, including the ability to send post requests, head requests, and get requests to the server.
  • HTTP Hypertext Transfer Protocol
  • the web crawler can obtain the data from the server and the server.
  • All the traffic data during the interaction that is, all the web page data of the data update system that can be loaded by the browser can be obtained, and then the traffic data that needs to be downloaded indicated by the first download purpose is filtered and saved from the interactive traffic data. What is obtained is all the webpage data of the data resource update system that can be loaded by the browser, and therefore, batch downloading of traffic data can be realized.
  • the obtained interaction data of the browser interaction traffic data may be classified to determine a data resource category to which each traffic data in the interactive traffic data belongs, and then according to the data resource category and the download purpose, The association relationship determines a first data resource category corresponding to the first download purpose, and downloads the traffic data belonging to the first data resource category in the interactive traffic data to the local.
  • the data resource category describes the category to which the traffic data corresponding to the download purpose belongs. For example, if the download purpose is image download, the category of the traffic data corresponding to the download purpose is an image, and the traffic data belonging to the category of pictures in the interactive traffic data is saved locally; for another example, if the download purpose is video download, then The category of the traffic data corresponding to the download purpose is video, and the traffic data belonging to the category of video in the interactive traffic data is saved locally.
  • FIG. 2 is a schematic flowchart of another method for acquiring data resources according to an embodiment of the present application. As shown in the figure, the method includes:
  • a scalable hypertext transmission request for a data resource update system is triggered by a web crawler, and the web crawler acquires data of the data resource update system by simulating a target mode, and the target mode is that the browser obtains the data through an HTTP request.
  • S202 Intercept the extensible hypertext transmission request and the return data corresponding to the extensible hypertext transmission request to obtain the interactive traffic data corresponding to the extensible hypertext transmission request, where the interactive traffic data includes the extensible hypertext transmission request.
  • the extended hypertext transfer request and the returned data are the extensible hypertext transmission request and the returned data.
  • steps S201 to S202 reference may be made to the description of steps S101 to S102 in the embodiment corresponding to FIG. 1, and details are not described herein again.
  • S203 Classify the interactive traffic data according to the format of the interactive traffic data.
  • the suffix format can be interactive in the formats of BMP, JPG, PNG, TIFF, GIF, PCX, TGA, EXIF, FPX, SVG, CDR, PCD, DXF, UFO, EPS, AI, RAW, WMF, WEBP, etc.
  • Traffic data is divided into traffic data belonging to the picture category; interactive traffic data with suffix formats of AU, AIFF, WQF, VQF, CD, APE, MP3, WMA, MIDI, WAV and other formats are divided into traffic data belonging to the audio category;
  • the suffix format is RM, RMVB, MTV, WMV, AVI, 3GP, DMV, FLV, DAT and other formats.
  • the interactive traffic data is classified as video data.
  • the interactive traffic data with suffix format is html. Traffic data; divides interactive traffic data in the format of word, word, txt, excel, pdf, etc. into traffic data belonging to the document category.
  • the number of traffic circled with a suffix of png in FIG. 3 can be divided into interactive traffic data belonging to the picture category, and circled in FIG. 3
  • the traffic data with the suffix of html is divided into interactive traffic data belonging to the URL category.
  • the data of the web page of the data resource update system crawled by the browser crawler component is classified according to the format of the interactive traffic data to determine the data resource category to which each traffic data belongs.
  • the classification is simple and required. Less calculation can realize the rapid classification of the interactive traffic data, so that the data belonging to the resource category corresponding to the download purpose can be saved locally.
  • FIG. 4 is a schematic flowchart of another method for obtaining data resources according to an embodiment of the present application. As shown in the figure, the method includes:
  • a scalable hypertext transmission request for a data resource update system is triggered by a web crawler, and the web crawler obtains data of the data resource update system by simulating a target mode, and the target mode is that the browser obtains the data through an HTTP request.
  • steps S301 to S302 reference may be made to the description of steps S101 to S102 in the embodiment corresponding to FIG. 1, and details are not described herein again.
  • the traffic data classification model is a classifier that is trained based on a classification algorithm and is used to classify the traffic data.
  • the traffic data classification model can be a classifier trained based on K nearest neighbor (KNN) algorithm, a classifier trained based on naive Bayes (NB) algorithm, or a decision tree
  • KNN K nearest neighbor
  • NB naive Bayes
  • the classifier trained by (decision tree) algorithm can also be a classifier trained based on logistic regression (LR) algorithm, or it can be trained based on support vector machine (SVM) algorithm
  • the classifier is not limited in the embodiment of the present application.
  • each traffic data in the interactive traffic data may be sequentially input into the traffic data classification model, and the data resource category to which each interactive traffic data belongs is determined according to the output of the traffic data classification model.
  • the traffic data “http://www.pingan.com” is sent to the traffic data classification model, and the output of the traffic data classification model is “URL”, the data resource to which the traffic data belongs is determined.
  • the category is URL.
  • the interactive traffic data before the interactive traffic data is classified as the input of a preset traffic data classification model, the interactive traffic data may also be implemented by using multiple data that has been classified into categories and data to which the multiple data belong.
  • the resource category trains the traffic data classification model to obtain the traffic data classification model that is closest to the actual situation.
  • the method includes: determining a plurality of traffic data and a data resource category to which the plurality of traffic data belongs; using the plurality of traffic data and a data resource category to which the plurality of traffic data belong as training samples, classifying the traffic data based on a classification algorithm
  • the model is trained to obtain a traffic data classification model closest to the training sample; and the traffic data classification model closest to the training sample is determined as the preset traffic data classification model.
  • the classification algorithm may be any one of KNN algorithm, NB algorithm, DT algorithm, LR algorithm, or SVM algorithm.
  • the data of the web page of the data resource update system crawled by the browser crawler component is used as the input of a pre-trained traffic data classification model, and the traffic data can be determined according to the output of the traffic data.
  • Data resource categories. Classification of traffic data based on a classification model can achieve accurate classification of interactive traffic data, so that data belonging to the resource category corresponding to the download purpose can be saved locally.
  • FIG. 5 is a schematic structural diagram of a device for acquiring data resources according to an embodiment of the present application.
  • the device 40 includes:
  • a request triggering module 401 is configured to trigger an extensible hypertext transmission request for a data resource update system through a web crawler, and the web crawler obtains data of the data resource update system by simulating a target mode, and the target mode is through a browser.
  • a manner in which an HTTP request acquires data of the data resource update system;
  • a traffic intercepting module 402 is configured to intercept the extensible hypertext transmission request and return data corresponding to the extensible hypertext transmission request to obtain interactive traffic data corresponding to the extensible hypertext transmission request, and the interactive traffic Data includes the extensible hypertext transmission request and the returned data;
  • the saving module 403 is configured to obtain, from the interactive traffic data, traffic data corresponding to the first downloading destination and save the traffic data locally.
  • the saving module 403 is specifically configured to:
  • Classifying the interactive traffic data to determine a data resource category corresponding to each traffic data in the interactive data traffic;
  • the saving module 403 is specifically configured to:
  • the saving module 403 is specifically configured to:
  • the device 40 further includes:
  • a determining module 404 configured to determine a plurality of traffic data and a data resource category to which the plurality of traffic data belongs;
  • a training module 405 is configured to use the multiple traffic data and data resource categories to which the multiple traffic data belong as training samples, and train a traffic data classification model based on a classification algorithm to obtain traffic data classification that is closest to the training sample. model;
  • a model determining module 406 is configured to determine the traffic data classification model closest to the training sample as the preset traffic data classification model.
  • the traffic interception module 402 is specifically configured to:
  • the extensible hypertext transmission object proxy intercepts the returned data corresponding to the extensible hypertext transmission request and the extensible hypertext transmission request.
  • the request triggering module 401 is specifically configured to:
  • batch downloading of traffic data may be implemented.
  • FIG. 6 is a schematic structural diagram of another apparatus for acquiring data resources according to an embodiment of the present application.
  • the apparatus 50 includes a processor 501, a memory 502, and a communication interface 503.
  • the processor 501 is connected to the memory 502 and the communication interface 503.
  • the processor 501 may be connected to the memory 502 and the communication interface 503 through a bus.
  • the processor 501 is configured to support the apparatus for acquiring data resources to perform corresponding functions in the website security detection method described in FIG. 1 to FIG. 4.
  • the processor 501 may be a Central Processing Unit (CPU), a Network Processor (NP), a hardware chip, or any combination thereof.
  • the above-mentioned hardware chip may be an Application-Specific Integrated Circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof.
  • the PLD may be a complex programmable logic device (Complex Programmable Logic Device, CPLD), a field programmable logic gate array (Field-Programmable Gate Array, FPGA), a universal array logic (Generic Array logic, GAL), or any combination thereof.
  • the memory 502 is used to store program code and the like.
  • the memory 502 may include volatile memory (Volatile Memory, VM), such as Random Access Memory (RAM); the memory 502 may also include non-volatile memory (Non-Volatile Memory, NVM), such as read-only Memory (Read-Only Memory, ROM), flash memory (Hard Disk Drive, HDD), or solid state drive (SSD); the memory 602 may also include a combination of the above types of memories.
  • the memory 502 is configured to store programs for acquiring data resources, interactive traffic data, and the like.
  • the communication interface 503 is configured to send or receive data.
  • the processor 501 may call the program code to perform the following operations:
  • An extensible hypertext transmission request to the data resource update system is triggered by a web crawler, and the web crawler obtains the data of the data resource update system by simulating a target web crawler, and the target mode is that the browser obtains all data through an HTTP request.
  • the traffic data corresponding to the first download destination is obtained from the interactive traffic data and saved locally.
  • each operation may also correspond to the corresponding description of the method embodiments shown in FIGS. 1-4; the processor 501 may also perform other operations in the foregoing method embodiments in cooperation with the communication interface 503.
  • An embodiment of the present application further provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program, where the computer program includes program instructions, and the program instructions, when executed by the computer, cause the computer to execute as described above.
  • the computer may be part of the device for acquiring data resources mentioned above. For example, it is the processor 501 described above.
  • the program can be stored in a computer-readable storage medium.
  • the program When executed, the processes of the embodiments of the methods described above may be included.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random, Access Memory, RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本申请公开获取数据资源的方法和装置,其中,方法包括:通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过超文本传输协议HTTP协议获取所述数据资源更新系统的数据的方式;截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。本申请的技术方案可实现对流量数据的批量下载。

Description

获取数据资源的方法和装置
本申请要求于2018年07月27日提交中国专利局、申请号为2018108419134、申请名称为“获取数据资源的方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,尤其涉及获取数据资源的方法和装置。
背景技术
随着互联网的发展,用户可以通过互联网进行购物、浏览视频、浏览小说、浏览图片等。互联网中有各种各样的信息和资源可以供人们浏览,用户也可以从互联网上下载图片、文档、视频等。其中,用户可以通过浏览器浏览各种资源,当用户浏览到某些有用或感兴趣的资源时,用户可以在浏览器上对这些资源进行下载。
目前,有一些网站为网站上的部分资源提供了批量下载的功能,但是不是对所有的资源都提供了批量下载的功能,对于这些无法批量下载的资源,如果用户想要下载全部的资源,则需要依次点选这些资源从而实现全部下载,过程较麻烦。
发明内容
本申请实施例提供获取数据资源的方法和装置,解决批量下载数据的过程比较麻烦的问题。
第一方面,提供一种获取数据资源的方法,包括:
通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求(extensible markup language hyper text transfer protocol request,XMLHttpRequest),所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过超文本传输协议(hyper text transfer protocol,HTTP)请求获取所述数据资源更新系统的数据的方式;
截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
第二方面,提供了一种获取数据资源的装置,其包括:
请求触发模块,用于通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式;
流量截取模块,用于截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
保存模块,用于从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
第三方面,提供另一种获取数据资源的装置,包括处理器、存储器以及通信接口,所述处理器、存储器和通信接口相互连接,其中,所述通信接口用于接收或发送数据,所述存储器用于存储获取数据资源的装置执行上述方法的应用程序代码,所述处理器被配置用于执行上述第一方面的方法。
第四方面,提供一种计算机存储介质,所述计算机存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述第一方面的方法。
本技术方案可以实现对流量数据的批量下载。
附图说明
图1是申请实施例提供的一种网站安全检测方法的流程示意图;
图2是本申请实施例提供的另一种获取数据资源的方法的流程示意图;
图3是本申请实施例提供的交互流量数据的示意图;
图4是本申请实施例提供的又一种获取数据资源的方法的流程示意图;
图5是本申请实施例提供的一种获取数据资源的装置的组成结构示意图;
图6是本申请实施例提供的另一种获取数据资源的装置的组成结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为便于理解本申请实施例的技术方案,首先对申请实施例涉及的XMLHttpRequest对象进行介绍。
XMLHttpRequest对象是XMLHttp组件(浏览器中的组件)的对象,通过这个对象,Ajax可以像桌面应用程序一样只与服务器进行数据层的交换,而不必每次都刷新界面,也不必将数据处理的工作都交给服务器来做,这样可以减轻服务器负担,同时加快响应速度,缩短用户等待页面显示的时间。在Ajax应用程序中,XMLHttpRequest对象负责将用户信息异步通信地发送到服务器端,并接收服务器响应信息和数据。XMLHttpRequest对象可以向服务器发起异步HTTP请求,监听服务器状态,并在服务器完成数据响应处理之后接收服务器端返回的信息数据。
接下来介绍申请实施例的技术方案。
参见图1,图1是申请实施例提供的一种网站安全检测方法的流程示意图,如图所示,该方法包括:
S101,通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式。
本申请实施例中,数据资源更新系统可以为一个提供数据资源下载服务的网站系统,数据资源可以为文档、图片、视频、音频等资源。
本申请实施例中,网络爬虫可以模拟浏览器行为,像浏览器一样实现与服务器之间的数据交互的网络爬虫,网络爬虫可以从数据资源更新系统的一个初始的URL开始,通过模拟浏览器与数据资源更新系统对应的后台服务器之间交互的方式依次爬取数据资源更新系统中的各个URL,从而得到数据更新资源系统中的网页的内容。XMLHttpRequest请求是指网络爬虫的XMLHttpRequest对象模拟浏览器的XMLHttpRequest对象向服务器发起的异步HTTP请求。本申请实施例中,通过网络爬虫触发的XMLHttpRequest请求包括该网络爬虫从数据资源更新系统的一个URL开始在爬取网站系统中的各个URL对应的网页的数据的整个过程中向数据资源更新系统对应的后台服务器发起的每一次异步HTTP请求。
这里,通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求是指模拟真实的浏览器与数据资源更新系统对应的后台服务器进行多次异步传输和加载的过程,其中,数据资源更新系统对应的后台服务器用于管理和维护数据资源更新系统的各种资源,数据资源更新系统对应的后台服务器还用于向浏览器提供该网站系统的资源。模拟真实的浏览器与数据资源更新系统对应的后台服务器进行多次异步传输和加载的过程具体可以为:首先,在本地创建网络爬虫的XMLHttpRequeset对象,并为该XMLHttpRequeset对象注册回调方法;然后,设置网络爬虫与数据资源更新系统对应的后台服务器交互的相应参数以及向数据资源更新系统对应的后台服务器发送的数据;最后,启动网络爬虫与数据资源更新系统对应的后台服务器之间的通信交互。可选地,在启动网络爬虫与网站系统对应的后台服务器之间的通信交互的过程中,还可以模拟用户对网络爬虫的一系列操作以持续触发对数据资源更新系统的XMLHttpRequest请求,具体可包括模拟用户登录、模拟点击网页上的链接,下拉网页,等等。
S102,截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据。
本申请实施例中,截取XMLHttpRequest请求以及XMLHttpRequest请求 对应的返回数据是指:截取通过网络爬虫模拟的浏览器与数据资源更新系统对应的后台服务器进行异步传输和加载的过程中的目标请求和目标数据。目标请求为模拟浏览器向数据资源更新系统对应的后台服务器发送的一个或多个请求,目标请求可以为访问请求,如访问网站系统的某一页面的请求;目标请求也可以为参数提交请求,如提交通过参数获取页面获取到的参数的请求;目标请求也可以为参数查询请求、参数修改请求,等等,不限于这里的描述。目标数据为网站系统对应的后台服务器根据该目标请求返回的数据,例如,目标请求为访问请求,则目标数据为该访问请求对应的页面的页面数据;又如,目标请求为参数提交请求,则目标数据为响应该参数提交请求的数据。
在一种具体的实现方式中,可以通过在网络爬虫中对XMLHttpRequest对象设置代理的方式截取该XMLHttpRequest请求以及该XMLHttpRequest请求对应的返回数据,其具体可以为:
第一步,备份网络爬虫的XMLHttpRequest对象下的所有方法和所有属性。
本申请实施例中,XMLHttpRequest对象下的所有方法包括abort()方法、getAllResponseHeaders()方法、getResponseHeader()方法、open()方法、send()方法以及setRequestHeader()方法。其中,abort()方法用于取消当前所发出的请求;getAllResponseHeaders()方法用于获取所有的HTTP头信息;getResponseHeader()方法用于获取一个指定的HTTP头信息;open()方法用于创建一个HTTP请求,并指定请求的模式,如get请求或post请求;send()方法用于将创建的请求发送给网站系统对应的服务器,并接收相应的回应信息,即接收返回数据;setRequestHeader()方法用于设置一个指定请求的HTTP头信息。
XMLHttpRequest对象下的所有属性包括readyState属性、Onreadysatatechage属性、responeText属性、responseXML属性、status属性以及statusText属性。其中,readyState属性的值为0~4,用于指示一次交互过程的进度情况,readyState的值为0表示初始化状态,XMLHttpRequest对 象已创建或已被abort()方法重置;readyState的值为1表示open()方法已经被调用,但是send()方法还未被调用,即请求还没有被发送;readyState的值为2表示send()方法已经被调用,HTTP请求已经发送到网站系统对应的后台服务器,还未收到响应;readyState的值为3表示所有响应头部都已经接收到,响应已经开始接收但未完成;readyState的值为表示HTTP响应已经完全接收。responseText属性用于指示当前接收到的后台服务器接收到的响应数据,如果还没有接收到数据的话,responseText属性为空字符串。如果readyState小于3,responseText属性为空字符串。当readyState为3时,responseText属性为当前已经接收的响应数据。如果readyState为4,responseText属性属性保存了完整的响应数据。responseXML属性用于表示对请求的响应,其被解析为XML。status属性为网站系统对应的后台服务器返回的HTTP状态代码,如200表示请求成功,而404表示“Not Found”错误。statusText属性返回当前请求的响应行状态。当状态为200的时候它是“OK”,当状态为404的时候它是“Not Found”。
具体实现中,可以将XMLHttpRequest对象下的所有方法和所有属性保存到全局对象中以完成对XMLHttpRequest对象下的所有方法和所有属性的备份。
第二步,通过方法重写覆盖XMLHttpRequest对象得到XMLHttpRequest对象对应的XMLHttpRequest对象代理。
这里,通过方法重写覆盖XMLHttpRequest对象得到XMLHttpRequest对象对应的XMLHttpReques对象代理的具体方式为:创建保存在全局对象中的XMLHttpRequest对象对应的XMLHttpRequest实例,遍历该XMLHttpRequest实例的所有属性和所有方法,为该XMLHttpRequest实例的各个方法生成其对应的代理方法,为XMLHttpRequest实例的各个属性生成其对应的代理属性。
第三步,通过XMLHttpRequest对象代理截取该XMLHttpRequest请求以及该XMLHttpRequest请求对应的返回数据。
具体实现中,当网络爬虫通过XMLHttpRequest对象发起 XMLHttpRequest请求时,各个代理方法拦截模拟浏览器发起的XMLHttpRequest请求,然后对该XMLHttpRequest请求进行放行以使该XMLHttpRequest请求可以发送至网站系统对应的后台服务器,当该网站系统对应的后台服务器返回XMLHttpRequest请求对应的返回数据时,代理方法拦截该返回数据,然后再对该返回数据进行放行以使该返回数据可以传输至网络爬虫。
S103,从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
这里,第一下载目的可以为预先设置的目的,也可以使用户指定的下载目的。其中,在第一下载目的为用户指定的下载目的的情况下,可以向用户显示多个下载目的选项,根据用户对这多个下载目的选择的选择确定第一下载目的。第一下载目的用于表示需要在该数据资源更新系统中下载的流量数据的内容或者类别。例如,第一下载目的为图片下载,则表示需要在该数据更新系统中下载的流量数据为图片数据;又如,第一下载目的为视频下载,则表示需要在该数据更新系统中下载的流量数据为视频数据;又如,第一下载目的为文档下载,则表示需要在该数据更新系统中下载的流量数据为文档数据;又如,第一下载目的为音频下载,则表示需要在该数据更新系统中下载的流量数据为音频数据;又如,第一下载目的为URL下载,则表示需要在该数据更新系统中要下载的流量数据为URL数据;不限于这里的描述。
具体实现中,可以从该交互流量数据中筛选出第一下载目的所表示的需要下载的流量数据,然后将筛选得到的流量数据保存到本地。
本申请实施例中,网络爬虫为一种以模拟浏览器的方式获取网站系统的数据的网络爬虫,网络爬虫可以获取数据资源更新系统中的所有的网页的数据,网络爬虫的XMLHttpRequest对象提供了对超文本传输(hyper text transfer protocol,HTTP)协议的完全访问,包括向服务器发出post请求、head请求以及get请求的能力,通过截取XMLHttpRequest请求以及XMLHttpRequest请求对应的返回数据可以获取到网络爬虫在与服务器交互的过程中的所有流量数据,即可以获取到浏览器可以加载的该数据更新系统的所有网页数据, 然后从交互流量数据中筛选并保存第一下载目的所表示的需要下载的流量数据,由于获取到的是浏览器可以加载的该数据资源更新系统的所有网页数据,因此,可实现对流量数据的批量下载。
在一些可能的场景中,可以对获取到的浏览器交互流量数据的交互数据进行分类,以确定交互流量数据中的各个流量数据所属的数据资源类别,然后根据数据资源类别与下载目的之间的关联关系确定与第一下载目的对应的第一数据资源类别,将交互流量数据中的属于第一数据资源类别的流量数据下载到本地。
示例性地,数据资源类别与下载目的的关联关系可以如表1所示:
数据资源类别 下载目的
图片 图片下载
音频 音频下载
视频 视频下载
文档 文档下载
URL URL
表1
其中,数据资源类别描述了与下载目的对应的流量数据所属的类别。例如,下载目的为图片下载,则与下载目的对应的流量数据所属的类别为图片,则将交互流量数据中属于图片这一类别的流量数据保存到本地;又如,下载目的为视频下载,则与下载目的对应的流量数据所属的类别为视频,则将交互流量数据中属于视频这一类别的流量数据保存到本地。
本申请实施例中,可以有两种方式对交互流量数据进行分分类。以下介绍采用不同的方式对交互流量数据进行分类以将属于与第一下载目的对应的数据资源类别的数据流量下载到本地的具体实现方式。参见图2-图3。
参见图2,图2是本申请实施例提供的另一种获取数据资源的方法的流程示意图,如图所示,该方法包括:
S201,通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求, 所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式。
S202,截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据。
这里,步骤S201~S202的具体实现方式可参见图1对应的实施例中步骤S101~S102的描述,此处不再赘述。
S203,根据所述交互流量数据的格式对所述交互流量数据进行分类。
这里,不同类别的流量数据,其对应的不同的格式。具体实现中,可以将后缀格式为BMP、JPG、PNG、TIFF、GIF、PCX、TGA、EXIF、FPX、SVG、CDR、PCD、DXF、UFO、EPS、AI、RAW、WMF、WEBP等格式的交互流量数据划分为属于图片类别的流量数据;将后缀格式为AU、AIFF、WQF、VQF、CD、APE、MP3、WMA、MIDI、WAV等格式的交互流量数据划分为属于音频类别的流量数据;将后缀格式为RM、RMVB、MTV、WMV、AVI、3GP、DMV、FLV、DAT等格式的交互流量数据划分为属于视频类别的流量数据;将后缀格式为html的交互流量数据划分为属于URL类别的流量数据;将格式为word、word、txt、excel、pdf等格式的交互流量数据划分为属于文档类别的流量数据。
举例来进行说明,例如获取到的部分交互流量数据如图3所示,则可以将图3中圈出的后缀为png的流量数划分为属于图片类别的交互流量数据,将图3中圈出的后缀为html的流量数据划分为属于URL类别的交互流量数据。
S204,根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别。
S205,将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
这里,步骤S204~S205的具体实现方式可参考前述描述,此处不再赘述。
本申请实施例中,通过根据交互流量数据的格式对通过浏览器爬虫组件 爬取到的数据资源更新系统的网页的数据进行分类分别确定各个流量数据所属的数据资源类别,分类方式简单,需要的计算少,可以实现对交互流量数据的快速分类,从而可以快速地将属于下载目的对应的资源类别的数据保存到本地。
参见图4,图4是本申请实施例提供的又一种获取数据资源的方法的流程示意图,如图所示,该方法包括:
S301,通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式。
S302,截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据。
这里,步骤S301~S302的具体实现方式可参见图1对应的实施例中步骤S101~S102的描述,此处不再赘述。
S303,将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类。
这里,流量数据分类模型为基于分类算法训练得到的用于对流量数据进行分类的分类器。该流量数据分类模型可以为基于K近邻(K nearest neighbor,KNN)算法训练得到的分类器,也可以为朴素贝叶斯(naive Bayes,NB)算法训练得到的分类器,也可以是基于决策树(decision tree,DT)算法训练得到的分类器,也可以是基于逻辑回归(logistic regression,LR)算法训练得到的分类器,也可以是基于支持向量机(support vector machine,SVM)算法训练得到的分类器,本申请实施例不做限制。
具体实现中,可以将交互流量数据中的各个流量数据依次送入该流量数据分类模型中,根据该流量数据分类模型的输出确定各个交互流量数据所属的数据资源类别。
例如,将流量数据“http://www.pingan.com”,将流量数据送入该流量数据分类模型中,该流量数据分类模型的输出为“URL”,则确定该流量数据所 属的数据资源类别为URL。
在可选实施方式中,在将交互流量数据作为预设的流量数据分类模型的输入对交互流量数据进行分类之前,还可以利用实现已经分好类别的多个数据以及该多个数据所属的数据资源类别对流量数据分类模型进行训练,以得到最接近于实际情况的流量数据分类模型,在将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类之前还包括:确定多个流量数据以及所述多个流量数据所属的数据资源类别;将所述多个流量数据以及所述多个流量数据所属的数据资源类别作为训练样本,基于分类算法对流量数据分类模型进行训练得到最逼近所述训练样本的流量数据分类模型;将所述最逼近所述训练样本的流量数据分类模型确定为所述预设的流量数据分类模型。
其中,分类算法可以为KNN算法、NB算法、DT算法、LR算法或SVM算法中的任意一种算法。
S304,根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别。
S305,将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
这里,步骤S304~S305的具体实现方式可参考前述描述,此处不再赘述。
本申请实施例中,通过将通过浏览器爬虫组件爬取到的数据资源更新系统的网页的数据作为预先训练好的流量数据分类模型的输入,根据该流量数据的输出可确定各个流量数据所属的数据资源类别,基于分类模型对流量数据进行分类可以实现对交互流量数据的准确分类,从而可以准确地将属于下载目的对应的资源类别的数据保存到本地。
上面介绍了本申请实施例的方法,下面介绍本申请实施例的装置。
参见图5,图5是本申请实施例提供的一种获取数据资源的装置的组成结构示意图,该装置40包括:
请求触发模块401,用于通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新 系统的数据,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式;
流量截取模块402,用于截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
保存模块403,用于从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
在一种可能的设计中,所述保存模块403具体用于:
对所述交互流量数据进行分类,以确定所述交互数据流量中的各个流量数据对应的数据资源类别;
根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别;
将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
在一种可能的设计中,所述保存模块403具体用于:
根据所述交互流量数据的格式对所述交互流量数据进行分类。
在一种可能的设计中,所述保存模块403具体用于:
将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类。
在一种可能的设计中,所述装置40还包括:
确定模块404,用于确定多个流量数据以及所述多个流量数据所属的数据资源类别;
训练模块405,用于将所述多个流量数据以及所述多个流量数据所属的数据资源类别作为训练样本,基于分类算法对流量数据分类模型进行训练得到最逼近所述训练样本的流量数据分类模型;
模型确定模块406,用于将所述最逼近所述训练样本的流量数据分类模型确定为所述预设的流量数据分类模型。
在一种可能的设计中,所述流量截取模块402具体用于:
备份所述网络爬虫的可扩展超文本传输对象下的所有方法和所有属性;
通过方法重写覆盖所述可扩展超文本传输对象得到所述可扩展超文本传输对象对应的可扩展超文本传输对象代理;
通过所述可扩展超文本传输对象代理截取所述可扩展超文本传输请求对应以及所述可扩展超文本传输请求对应的返回数据。
在一种可能的设计中,所述请求触发模块401具体用于:
在本地创建所述网络爬虫的可扩展超文本传输对象,并为所述可扩展超文本传输对象注册回调方法;
设置与所述数据资源更新系统对应的后台服务器交互的参数和向所述后台服务器发送的流量数据;
启动与所述后台服务器的通信交互。
需要说明的是,图5对应的实施例中未提及的内容可参见方法实施例的描述,这里不再赘述。
本申请实施例中,可以实现对流量数据的批量下载。
参见图6,图6是本申请实施例提供的另一种获取数据资源的装置的组成结构示意图,该装置50包括处理器501、存储器502以及通信接口503。处理器501连接到存储器502和通信接口503,例如处理器501可以通过总线连接到存储器502和通信接口503。
处理器501被配置为支持所述获取数据资源的装置执行图1-图4所述的网站安全检测方法中相应的功能。该处理器501可以是中央处理器(Central Processing Unit,CPU),网络处理器(Network Processor,NP),硬件芯片或者其任意组合。上述硬件芯片可以是专用集成电路(Application-Specific Integrated Circuit,ASIC),可编程逻辑器件(Programmable Logic Device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(Complex Programmable Logic Device,CPLD),现场可编程逻辑门阵列(Field-Programmable Gate Array,FPGA),通用阵列逻辑(Generic Array Logic,GAL)或其任意组合。
存储器502存储器用于存储程序代码等。存储器502可以包括易失性存 储器(Volatile Memory,VM),例如随机存取存储器(Random Access Memory,RAM);存储器502也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如只读存储器(Read-Only Memory,ROM),快闪存储器(flash memory),硬盘(Hard Disk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);存储器602还可以包括上述种类的存储器的组合。本申请实施例中,存储器502用于存储获取数据资源的程序、交互流量数据等。
所述通信接口503用于发送或接收数据。
处理器501可以调用所述程序代码以执行以下操作:
通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据的网络爬虫,所述目标方式为浏览器通过HTTP请求获取所述数据资源更新系统的数据的方式;
截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
需要说明的是,各个操作的实现还可以对应参照图1-图4所示的方法实施例的相应描述;所述处理器501还可以与通信接口503配合执行上述方法实施例中的其他操作。
本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被计算机执行时使所述计算机执行如前述实施例所述的方法,所述计算机可以为上述提到的获取数据资源的装置的一部分。例如为上述的处理器501。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。

Claims (20)

  1. 一种获取数据资源的方法,其特征在于,包括:
    通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过超文本传输协议HTTP获取所述数据资源更新系统的数据的方式;
    截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
    从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
  2. 根据权利要求1所述的方法,其特征在于,所述从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地包括:
    对所述交互流量数据进行分类,以确定所述交互数据流量中的各个流量数据所属的数据资源类别;
    根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别;
    将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
  3. 根据权利要求2所述的方法,其特征在于,所述对所述交互流量数据进行分类包括:
    根据所述交互流量数据的格式对所述交互流量数据进行分类。
  4. 根据权利要求2所述的方法,其特征在于,所述对所述交互流量数据进行分类包括:
    将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类。
  5. 根据权利要求4所述的方法,其特征在于,所述对所述交互流量数据进行分类之前还包括:
    确定多个流量数据以及所述多个流量数据所属的数据资源类别;
    将所述多个流量数据以及所述多个流量数据所属的数据资源类别作为训练样本,基于分类算法对流量数据分类模型进行训练得到最逼近所述训练样本的流量数据分类模型;
    将所述最逼近所述训练样本的流量数据分类模型确定为所述预设的流量数据分类模型。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述截取所述可扩展超文本传输请求对应以及所述可扩展超文本传输请求对应的返回数据包括:
    备份所述网络爬虫的可扩展超文本传输对象下的所有方法和所有属性;
    通过方法重写覆盖所述可扩展超文本传输对象得到所述可扩展超文本传输对象对应的可扩展超文本传输对象代理;
    通过所述可扩展超文本传输对象代理截取所述可扩展超文本传输请求对应以及所述可扩展超文本传输请求对应的返回数据。
  7. 根据权利要求1-5任一项所述的方法,其特征在于,所述通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求包括:
    在本地创建所述网络爬虫的可扩展超文本传输对象,并为所述可扩展超文本传输对象注册回调方法;
    设置与所述数据资源更新系统对应的后台服务器交互的参数和向所述后台服务器发送的流量数据;
    启动与所述后台服务器的通信交互。
  8. 一种获取数据资源的装置,其特征在于,包括:
    请求触发模块,用于通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫为通过模拟目标方式获取所述数据资源更新系统的数据的网络爬虫,所述目标方式为浏览器获取所述数据资源更新系统的数据的方式;
    流量截取模块,用于截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求中的数据和 所述返回数据;
    保存模块,用于从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
  9. 根据权利要求8所述的装置,其特征在于,所述保存模块具体用于:
    对所述交互流量数据进行分类,以确定所述交互数据流量中的各个流量数据对应的数据资源类别;
    根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别;
    将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
  10. 根据权利要求9所述的装置,其特征在于,所述保存模块具体用于:
    根据所述交互流量数据的格式对所述交互流量数据进行分类。
  11. 根据权利要求9所述的装置,其特征在于,所述保存模块具体用于:
    将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类。
  12. 根据权利要求11所述的装置,其特征在于,所述装置还包括:
    确定模块,用于确定多个流量数据以及所述多个流量数据所属的数据资源类别;
    训练模块,用于将所述多个流量数据以及所述多个流量数据所属的数据资源类别作为训练样本,基于分类算法对流量数据分类模型进行训练得到最逼近所述训练样本的流量数据分类模型;
    模型确定模块,用于将所述最逼近所述训练样本的流量数据分类模型确定为所述预设的流量数据分类模型。
  13. 根据权利要求8-12所述的装置,其特征在于,所述流量截取模块具体用于:
    备份所述网络爬虫的可扩展超文本传输对象下的所有方法和所有属性;
    通过方法重写覆盖所述可扩展超文本传输对象得到所述可扩展超文本传输对象对应的可扩展超文本传输对象代理;
    通过所述可扩展超文本传输对象代理截取所述可扩展超文本传输请求对应以及所述可扩展超文本传输请求对应的返回数据。
  14. 根据权利要求8-12所述的装置,其特征在于,所述请求触发模块具体用于:
    在本地创建所述网络爬虫的可扩展超文本传输对象,并为所述可扩展超文本传输对象注册回调方法;
    设置与所述数据资源更新系统对应的后台服务器交互的参数和向所述后台服务器发送的流量数据;
    启动与所述后台服务器的通信交互。
  15. 一种获取数据资源的装置,包括处理器、存储器以及通信接口,所述处理器、存储器和通信接口相互连接,其中,所述通信接口用于传输数据,所述存储器用于存储程序代码,所述处理器用于调用所述程序代码,执行以下操作:
    通过网络爬虫触发对数据资源更新系统的可扩展超文本传输请求,所述网络爬虫通过模拟目标方式获取所述数据资源更新系统的数据,所述目标方式为浏览器通过超文本传输协议HTTP获取所述数据资源更新系统的数据的方式;
    截取所述可扩展超文本传输请求以及所述可扩展超文本传输请求对应的返回数据,以获取所述可扩展超文本传输请求对应的交互流量数据,所述交互流量数据包括所述可扩展超文本传输请求和所述返回数据;
    从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地。
  16. 根据权利要求15所述的装置,其特征在于,所述处理器执行所述从所述交互流量数据中获取与第一下载目的对应的流量数据保存到本地的操作,包括:
    对所述交互流量数据进行分类,以确定所述交互数据流量中的各个流量数据所属的数据资源类别;
    根据数据资源类别与下载目的的关联关系确定与所述第一下载目的对应的第一数据资源类别;
    将所述交互流量数据中属于所述第一数据资源类别的流量数据保存到本地。
  17. 根据权利要求16所述的装置,其特征在于,所述处理器执行所述对所述交互流量数据进行分类的操作,包括:
    根据所述交互流量数据的格式对所述交互流量数据进行分类。
  18. 根据权利要求16所述的装置,其特征在于,所述处理器执行所述对所述交互流量数据进行分类的操作,包括:将所述交互流量数据作为预设的流量数据分类模型的输入对所述交互流量数据进行分类。
  19. 根据权利要求18所述的装置,其特征在于,所述处理器还用于执行以下操作:
    确定多个流量数据以及所述多个流量数据所属的数据资源类别;
    将所述多个流量数据以及所述多个流量数据所属的数据资源类别作为训练样本,基于分类算法对流量数据分类模型进行训练得到最逼近所述训练样本的流量数据分类模型;
    将所述最逼近所述训练样本的流量数据分类模型确定为所述预设的流量数据分类模型。
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
PCT/CN2018/107635 2018-07-27 2018-09-26 获取数据资源的方法和装置 Ceased WO2020019476A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810841913.4A CN109150984B (zh) 2018-07-27 2018-07-27 获取数据资源的方法和装置
CN201810841913.4 2018-07-27

Publications (1)

Publication Number Publication Date
WO2020019476A1 true WO2020019476A1 (zh) 2020-01-30

Family

ID=64798213

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/107635 Ceased WO2020019476A1 (zh) 2018-07-27 2018-09-26 获取数据资源的方法和装置

Country Status (2)

Country Link
CN (1) CN109150984B (zh)
WO (1) WO2020019476A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860512A (zh) * 2021-01-29 2021-05-28 平安国际智慧城市科技股份有限公司 接口监控的优化方法、装置、计算机设备及存储介质
CN114490817A (zh) * 2022-01-21 2022-05-13 百度在线网络技术(北京)有限公司 一种流量分类方法、装置、电子设备、介质及产品
CN115484321A (zh) * 2022-06-21 2022-12-16 国网信息通信产业集团有限公司 一种可配置多协议的svg交互采集方法、系统及svg设备

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103229486A (zh) * 2012-12-03 2013-07-31 华为技术有限公司 批量文件传输方法及设备
CN105426549A (zh) * 2015-12-29 2016-03-23 北京金山安全软件有限公司 一种读取网页资源的方法、装置及电子设备
CN106657228A (zh) * 2016-09-27 2017-05-10 山东浪潮云服务信息科技有限公司 一种利用云端进行并发采集的爬虫实现方法

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060190561A1 (en) * 2002-06-19 2006-08-24 Watchfire Corporation Method and system for obtaining script related information for website crawling
US20100153539A1 (en) * 2008-12-15 2010-06-17 Gregory Thomas Zarroli Algorithm for classification of browser links
CN101515300B (zh) * 2009-04-02 2011-07-20 阿里巴巴集团控股有限公司 一种Ajax网页内容的抓取方法及系统
CN101848116A (zh) * 2010-04-21 2010-09-29 中国海洋大学 一种简单快捷自动的Web服务器压力测试方法
CN102184227B (zh) * 2011-05-10 2013-05-08 北京邮电大学 一种面向web服务的通用爬虫引擎系统及其工作方法
CN102254027B (zh) * 2011-07-29 2013-05-08 四川长虹电器股份有限公司 批量获取网页内容的方法
CN104601522B (zh) * 2013-10-30 2018-01-30 中国移动通信集团北京有限公司 移动客户端与业务系统交互的实现方法、装置及系统
CN105045887B (zh) * 2015-07-24 2018-06-22 苏州工业园区迪锐信信息科技有限责任公司 混合模式跨域数据交互的系统及其方法
CN106997298B (zh) * 2016-01-22 2021-08-06 菜鸟智能物流控股有限公司 一种应用资源获取方法及装置
CN106650610A (zh) * 2016-11-02 2017-05-10 厦门中控生物识别信息技术有限公司 一种人脸表情数据收集方法及装置

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103229486A (zh) * 2012-12-03 2013-07-31 华为技术有限公司 批量文件传输方法及设备
CN105426549A (zh) * 2015-12-29 2016-03-23 北京金山安全软件有限公司 一种读取网页资源的方法、装置及电子设备
CN106657228A (zh) * 2016-09-27 2017-05-10 山东浪潮云服务信息科技有限公司 一种利用云端进行并发采集的爬虫实现方法

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860512A (zh) * 2021-01-29 2021-05-28 平安国际智慧城市科技股份有限公司 接口监控的优化方法、装置、计算机设备及存储介质
CN114490817A (zh) * 2022-01-21 2022-05-13 百度在线网络技术(北京)有限公司 一种流量分类方法、装置、电子设备、介质及产品
CN115484321A (zh) * 2022-06-21 2022-12-16 国网信息通信产业集团有限公司 一种可配置多协议的svg交互采集方法、系统及svg设备

Also Published As

Publication number Publication date
CN109150984B (zh) 2021-11-02
CN109150984A (zh) 2019-01-04

Similar Documents

Publication Publication Date Title
AU2015258733B2 (en) Methods and systems for web content generation
US20190340205A1 (en) Reducing redirects
US11288333B2 (en) Method and system for estimating user-item interaction data based on stored interaction data by using multiple models
RU2693323C2 (ru) Способ и сервер для выбора элементов рекомендаций для пользователя
US20180075137A1 (en) Method and apparatus for training a machine learning algorithm (mla) for generating a content recommendation in a recommendation system and method and apparatus for generating the recommended content using the mla
US20170199850A1 (en) Method and system to decrease page load time by leveraging network latency
US11822447B2 (en) Methods and servers for storing data associated with users and digital items of a recommendation system
CN104348919B (zh) 进行文件下载的方法、装置和浏览器
RU2714594C1 (ru) Способ и система определения параметра релевантность для элементов содержимого
WO2020019479A1 (zh) 网站安全检测方法和装置
CN105284075A (zh) 基于为网页的网页元素聚合用户偏好的优化网页加载
CN105556501A (zh) 令牌捎带的系统和方法
CN110020305A (zh) 网页加载方法、装置、计算机设备和存储介质
WO2020019476A1 (zh) 获取数据资源的方法和装置
CN105740417A (zh) 一种基于网页的目标数据搜索方法、模块、浏览器及终端
US10021210B1 (en) Providing faster data access using multiple caching servers
US9519710B1 (en) Dynamic classification of attribute relevance and classification
US11706472B2 (en) Modifying event playlists
US20240037174A1 (en) Client-side generation of lossless object model representations of dynamic webpages
WO2015154270A1 (zh) 一种信息搜索的方法以及装置
US20220075840A1 (en) Deep learning approach to mitigate the cold-start problem in textual items recommendations
CN116361588B (zh) 一种网络资源加载方法、装置、电子设备及存储介质
US12026166B2 (en) Method and system for determining rank positions of elements by a ranking system
US20230106483A1 (en) Seo pipeline infrastructure for single page applications with dynamic content and machine learning
CN109460531B (zh) 网页管理方法、装置及智能终端

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18927956

Country of ref document: EP

Kind code of ref document: A1