WO2020000747A1 - 一种反爬虫方法、终端及计算机可读存储介质 - Google Patents

一种反爬虫方法、终端及计算机可读存储介质 Download PDF

Info

Publication number
WO2020000747A1
WO2020000747A1 PCT/CN2018/108672 CN2018108672W WO2020000747A1 WO 2020000747 A1 WO2020000747 A1 WO 2020000747A1 CN 2018108672 W CN2018108672 W CN 2018108672W WO 2020000747 A1 WO2020000747 A1 WO 2020000747A1
Authority
WO
WIPO (PCT)
Prior art keywords
terminal
mining script
mining
script
target webpage
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/108672
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 WO2020000747A1 publication Critical patent/WO2020000747A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/54Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by adding security routines or objects to programs

Definitions

  • the present application relates to the field of communication technologies, and in particular, to an anti-crawling method, a terminal, and a computer-readable storage medium.
  • crawlers on the Internet are mainly divided into static crawlers and dynamic crawlers.
  • static crawlers cannot parse JavaScript (JS for short) code
  • the response method for static crawlers is usually to add JS code to the webpage to perform JS rendering on the webpage. Way to achieve the purpose of anti-climbing.
  • this method of JS rendering web pages cannot achieve the purpose of anti-crawling for dynamic crawlers that can parse JS. Therefore, how to prevent the effects of reptiles more effectively and improve the security of the Internet has become a research hotspot.
  • the embodiments of the present application provide an anti-crawling method, terminal and computer-readable storage medium, which can improve the effectiveness of anti-crawling and improve the security of the Internet.
  • an embodiment of the present application provides an anti-reptile method, which includes:
  • JS mining script library includes at least one JS mining script
  • a terminal that accesses the target webpage is triggered to load and execute the at least one JS mining script.
  • an embodiment of the present application provides a terminal, and the terminal includes a unit for executing the method in the first aspect.
  • an embodiment of the present application provides another terminal, including a processor, an input device, an output device, and a memory.
  • the processor, the input device, the output device, and the memory are connected to each other, where the memory is used for storing
  • a computer program supporting a terminal to execute the above method the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect.
  • an embodiment of the present application provides a computer-readable storage medium.
  • the computer storage medium stores a computer program, where the computer program includes program instructions, and the program instructions cause the processing when executed by a processor.
  • the processor performs the method of the first aspect.
  • a terminal accessing the target webpage is triggered to load and execute the JS mining script, preventing a crawler terminal from bypassing JS rendering and crawling data.
  • FIG. 1 is a schematic flowchart of an anti-crawler method provided by an embodiment of the present application
  • FIG. 2 is a schematic flowchart of another anti-crawler method provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of another anti-crawler method provided by an embodiment of the present application.
  • FIG. 4 is a schematic block diagram of a terminal according to an embodiment of the present application.
  • FIG. 5 is a schematic block diagram of another terminal according to an embodiment of the present application.
  • the anti-crawling method provided by the embodiment of the present application may be executed by a terminal, and the terminal may be a smart terminal such as a mobile phone, a computer, a tablet, or a smart watch.
  • the terminal may be a smart terminal such as a mobile phone, a computer, a tablet, or a smart watch.
  • the following is an example of an anti-crawler method for a terminal.
  • This solution is an anti-crawler technical solution for dynamic crawlers that can parse JS.
  • the common anti-crawling strategy for web pages in the prior art is usually to add JS code to the web page to perform JS rendering processing to achieve anti-static crawling. Crawling, however, for dynamic crawlers that can parse JS, this method cannot achieve the purpose of anti-crawling, so this solution improves the anti-crawling strategy for dynamic crawlers that can parse JS.
  • the crawler process that can parse the dynamic crawler of JS has two cases: one is to parse the html source code directly; another is a special case: if the data of the web page is loaded asynchronously, such as the data loaded by ajax, then Dynamic crawlers that can parse JS cannot parse and view the source code.
  • dynamic crawlers that can parse JS often use some third-party tools such as the automatic test tool Selenium in a browser that supports the WebAssembly language or cooperate with no interface. Browser PhantomJs, which simulates the behavior of the browser to load data.
  • the WebAssembly is a web page assembly language running in a modern web browser, and the file extension is ".wasm".
  • this solution pre-writes at least one JS mining script and establishes a JS mining script library.
  • the JS mining script library At least one JS mining script written in advance generates a link to at least one JS mining script.
  • the generated link of the at least one JS mining script is embedded in a location area with a high probability of data information being crawled in the target webpage.
  • a terminal accessing the target webpage opens a webpage embedded in the target webpage
  • the link of at least one JS mining script is determined, the terminal accessing the target webpage is determined as a crawler terminal, and the terminal accessing the target webpage is triggered to automatically load and execute at least one JS mining script in the link to achieve anti-crawling the goal of.
  • FIG. 1 is a schematic flowchart of an anti-crawler method provided by an embodiment of the present application. As shown in FIG. 1, the method may be executed by a terminal. The specific explanation of the terminal is as described above, and is not described here. More details. Specifically, the method in the embodiment of the present application includes the following steps.
  • the terminal may establish a JS mining script library, wherein the JS mining script library established by the terminal includes one or more JS mining scripts.
  • the JS mining script library established by the terminal includes a first JS mining script and a second JS mining script.
  • the first JS mining script is a script of the WebAssembly language
  • the second JS mining script is a script of the JS language.
  • the first JS mining script is a script written according to the WebAssembly language.
  • a dynamic crawler capable of parsing JS usually uses Selenium and a Webdriver to call a browser to simulate browser operations, among them.
  • the browser invoked by using Selenium with Webdriver is a browser that supports the WebAssembly; or using Selenium with PhantomJS, a non-interface browser, to simulate browser operations. Therefore, the first JS mining script is written in the WebAssembly language for a browser or PhantomJS that supports the WebAssembly, which is often used by dynamic crawlers that can parse JS.
  • the second JS mining script is a script in JS language. Since a dynamic crawler capable of parsing JS can also directly parse the html source code for parsing using an ordinary browser that does not support WebAssembly, it was written in JS language. The second JS mining script.
  • S102 Generate a link of at least one JS mining script, and embed the link of at least one JS mining script in a target webpage.
  • the terminal may generate a link of at least one JS mining script, and embed the link of the at least one JS mining script in a target webpage.
  • the terminal may generate a link to at least one JS mining script according to a JS mining script library established by the first JS mining script and the second JS mining script, and mine the at least one JS
  • the script's link is embedded in the first location area of the landing page.
  • the first location area is determined according to a probability that data information of each location area in the target webpage is crawled recorded in a historical record. If a location area is determined from each location area of the target webpage If the probability that the data information is crawled is the largest, then it is determined that the location area with the highest probability that the data information is crawled is the first location area.
  • the target webpage includes a comment location area, a question location area, an image display location area, and an information display location area
  • the probability is 90%
  • the probability of crawling data information in the question location area is 60%
  • the probability of crawling data information in the image display location area is 20%
  • the probability of crawling data information in the information display position area is 50%. Compare the probability that the data information of the area is crawled, and determine that the probability that the data information of the comment location area is crawled is 90%, so determine that the comment location area in the target webpage is the first location area.
  • the first location area may be determined by crawling keywords based on data information of each location area in the target webpage recorded in the historical record. It is determined that the data information included in a certain location area is crawled with the most keywords, and then the location area is determined to be the first location area. For example, it is assumed that the target webpage includes a comment location area, a question location area, an image display location area, and an information display location area. If the historical information that records the data of the review location area is obtained, the number of keywords crawled is n.
  • the comment location area in the target webpage is a first location area.
  • the terminal accessing the target webpage is a crawler terminal
  • the efficiency of linking at least one JS mining script in the location area to improve the efficiency of anti-crawling.
  • the terminal may generate a link to the first mining script according to the obtained first JS mining script, and generate a link to the second mining script according to the obtained second JS mining script, and
  • the link of the first JS mining script is embedded in the second location area of the target webpage, and the link of the second JS mining script is embedded in the third location area of the target webpage.
  • the second location area is determined according to a probability that the WebAssembly language-supported browser crawls data information of each location area in the target webpage recorded in the historical record. It is determined in the location area that the data information of a certain location area is most likely to be crawled by a browser supporting the WebAssembly language, then it is determined that the location area with the highest probability of being crawled by a browser that supports the WebAssembly language is the second Location area.
  • the target webpage includes a comment position area, a question position area, an image display position area, and an information display position area. If data information of the comment position area and the question position area are recorded in the history record, the WebAssembly is supported.
  • the probability of crawling is 50%, and the probability that the data information of the comment location area is crawled by a browser supporting the WebAssembly language and the data information of the question location area is crawled by a browser that supports the WebAssembly language
  • the probability of the comparison is determined, and it is determined that the probability that the data information of the comment location area is crawled by a browser that supports the WebAssembly language is 80%, so the comment location area in the target webpage is determined to be the second location area.
  • the second location area may be determined based on the data information of each location area in the target webpage recorded in the history record by a keyword crawled by a browser supporting the WebAssembly language. It is determined from each location area of the target webpage that the data information included in a location area is crawled by the browser supporting the WebAssembly language with the most keywords, and then the location area is determined to be the second location area.
  • the target webpage includes a comment location area, a question location area, an image display location area, and an information display location area. If the data information of the review location area recorded in the history record is obtained, the browser that supports the WebAssembly language The number of keywords crawled is n, the data information of the question location area is crawled by a browser that supports the WebAssembly language is m, and the data information of the image display location area is crawled by a browser that supports the WebAssembly language.
  • the number of keywords taken is x
  • the data information of the information display location area is crawled by the browser that supports the WebAssembly language is y
  • the data information of each location area is crawled by the browser that supports the WebAssembly language.
  • the number of keywords taken is compared. If n> m> x> y, it can be determined that the data information of the comment location area is crawled by the browser that supports the WebAssembly language.
  • the number of keywords is the largest, so the target is determined.
  • the comment location area in the webpage is the second location area.
  • the third location area is determined according to a probability that the target webpage recorded in the history page is crawled by a browser that does not support the WebAssembly language, and the data information of each location area is crawled. It is determined that the probability that the data information of a certain location area is crawled by a browser that does not support the WebAssembly language in each location area of the target webpage is determined, and the probability that the browser is not supported by the WebAssembly language is determined to be crawled The largest location area is the third location area.
  • the target webpage includes a comment location area, a question location area, an image display location area, and an information display location area. If data information of the image display location area and the information display location area is recorded in the history record, it is not supported.
  • the browser crawling of the WebAssembly language, and the probability that the data information of the image display location area is crawled by a browser that does not support the WebAssembly language is 60%, and the data information of the information display location area is not supported
  • the third location area may also be determined according to data information of each location area in the target webpage recorded in a history record by keywords crawled by browsers that do not support the WebAssembly language. If it is determined from each location area of the target webpage that the data information included in a location area is crawled by a browser that does not support the WebAssembly language, the location area is determined to be the third location area.
  • the target webpage includes a comment location area, a question location area, an image display location area, and an information display location area
  • the WebAssembly language is not supported for browsing.
  • the number of keywords crawled by the browser is n
  • the data information of the question location area is crawled by the browser that does not support the WebAssembly language is m
  • the data information of the image display location area is not supported by the WebAssembly language.
  • the number of keywords crawled by the browser is x
  • the number of keywords crawled by the browser that does not support the WebAssembly language is y
  • the data information of each location region is supported by the WebAssembly language
  • the terminal accessing the target webpage is a crawler terminal
  • the browser used by the terminal accessing the target webpage supports WebAssembly
  • the terminal when the terminal embeds a link of at least one JS mining script in a target webpage, the terminal may add prompt information to the link of the at least one JS mining script to remind normal users who visit the target webpage not to click This link, and the link of the at least one JS mining script to which the prompt information is added is embedded in an arbitrary location area of the target webpage.
  • the terminal embeds a link to at least one JS mining script in the target webpage
  • the link of the mining script is embedded in the first location area on the target webpage.
  • the explanation of the target location area is as described above, and is not repeated here.
  • the terminal embeds the link of the first JS mining script in the second location area of the target webpage and the link of the second JS mining script in the third location area of the target webpage, respectively, Add a "Do Not Click" prompt to the link of the JS mining script and the link of the second JS mining script, and then embed the link of the first JS mining script that added the prompt to the target web page.
  • the second location area, and the third location area on the target webpage where the link of the second JS mining script to which the prompt information is added, wherein the second location area and the third location area are explained as before I will not repeat them here.
  • This embodiment can avoid, to a certain extent, a user who accesses a normal terminal of the target webpage from accidentally clicking a link to the at least one JS mining script embedded in the target webpage, thereby avoiding the normal terminal accessing the target webpage from being caused. damage.
  • the terminal accessing the target webpage when it is detected that a terminal accesses the target webpage, if it is detected that the link of at least one JS mining script embedded in the target webpage is opened, it is determined that the terminal accessing the target webpage is a crawler terminal, and access is triggered
  • the terminal of the target webpage loads and executes the at least one JS mining script to consume a large amount of CPU resources of the terminal accessing the target webpage, to achieve the purpose of anti-crawling, and to prevent the terminal from bypassing JS rendering to crawl the Landing page data information, thereby improving the effectiveness of anti-crawling and enhancing the security of the Internet.
  • the terminal may embed a link of at least one JS mining script in a target webpage, and when a start instruction of the link of the at least one JS mining script is detected, a terminal accessing the target webpage is triggered to load and Execute at least one JS mining script, thereby preventing the terminal accessing the target webpage from bypassing JS rendering and crawling data, and improving the effectiveness of anti-crawling.
  • FIG. 2 is a schematic flowchart of another anti-crawler method provided by an embodiment of the present application. As shown in FIG. 2, the method may be executed by a terminal. The specific explanation of the terminal is as described above, and is not described here. More details. Specifically, the method in the embodiment of the present application includes the following steps.
  • the terminal may establish a JS mining script library, and the JS mining script library includes a first JS mining script and a second JS mining script.
  • the explanation of the first JS mining script and the second JS mining script is as described above, and is not repeated here.
  • S202 Generate a link of at least one JS mining script, and embed the link of at least one JS mining script in a first location area of a target webpage.
  • the terminal may generate a link of the at least one JS mining script according to the obtained JS mining script library, and embed the link of the at least one JS mining script in a target area of a target webpage.
  • the specifics of the first location area are as described above, and details are not described herein again.
  • the terminal accessing the target webpage is triggered according to a language supported by a browser used by the terminal accessing the target webpage, Selecting the first JS mining script or the second JS mining script.
  • the terminal accessing the target webpage may determine whether the browser used by the terminal accessing the target webpage supports the WebAssembly language according to the browsing version number used by the terminal accessing the target webpage.
  • a terminal that accesses the target webpage is triggered to determine whether a browser version number used by the terminal that accesses the target webpage is a preset version. Any of a number collection. If it is determined that the browser version number used by the terminal accessing the target webpage is any one of the preset version number set, then it is determined that the browser used by the terminal accessing the target webpage supports the WebAssembly language, so the mining script from the JS Select the first JS mining script in the library.
  • the browser used by the terminal accessing the target webpage does not support the WebAssembly language, thereby mining from the JS Select the second JS mining script from the script library.
  • the terminal that triggers access to the target webpage determines whether the version number of the browser used by the terminal that accesses the target webpage is any one of a set of preset version numbers. If the browser version number is IE8, it can be determined that the browser used by the terminal accessing the target webpage is one of a set of preset version numbers. Therefore, the browser used by the terminal accessing the target webpage supports the WebAssembly language and mining from the JS Select the first JS mining script from the script library.
  • the terminal that triggers access to the target webpage determines whether the version number of the browser used by the terminal that accesses the target webpage is any one of a set of preset version numbers. If the browser version number is IE5, it can be determined that the browser used by the terminal accessing the target webpage is not any one of the preset version number set. Therefore, the browser used by the terminal accessing the target webpage does not support the WebAssembly language. Select the first JS mining script from the JS mining script library.
  • S204 The browser used by the terminal accessing the target webpage loads and executes the first JS mining script or the second JS mining script.
  • the terminal may call a browser used by the terminal accessing the target webpage to load and execute the first JS mining script or the second JS mining script selected by the terminal accessing the target webpage.
  • the terminal may invoke a browser used by the terminal accessing the target webpage. Load and execute the first JS mining script. For example, if it is detected that the terminal accessing the target webpage selects the script selected from the JS mining script library as the first JS mining script, assuming that the browser used by the terminal accessing the target webpage is determined to be IE8, then Call the browser IE8 used by the terminal accessing the target webpage to load and execute the first JS mining script.
  • the terminal may call a WebAssembly language that is not used by the terminal accessing the target webpage.
  • the browser loads and executes the second JS mining script. For example, if it is detected that the terminal accessing the target webpage selects the script from the JS mining script library as the second JS mining script, assuming that the browser used by the terminal accessing the target webpage is determined to be IE5, then access can be invoked The browser IE5 used by the terminal of the target webpage loads and executes the second JS mining script.
  • the terminal that accesses the target webpage is triggered to select the first one according to the language supported by the browser used by the terminal that accesses the target webpage.
  • JS mining script or second JS mining script and call the browser used by the terminal accessing the target web page to load and execute the first JS mining script or the second JS mining script selected by the terminal accessing the target web page to consume
  • the CPU resources of the terminal accessing the target webpage achieve the purpose of anti-crawl and improve the effectiveness of anti-crawl.
  • FIG. 3 is a schematic flowchart of another anti-crawler method provided by an embodiment of the present application. As shown in FIG. 3, the method may be executed by a terminal. The specific explanation of the terminal is as described above, and is not described here. More details. Specifically, the method in the embodiment of the present application includes the following steps.
  • the JS mining script library includes a first JS mining script and a second JS mining script.
  • the terminal may obtain a JS mining script library, where the JS mining script library includes a first JS mining script and a second JS mining script, and the first JS mining script and the second JS mining.
  • the JS mining script library includes a first JS mining script and a second JS mining script
  • the first JS mining script and the second JS mining The explanation of the mine script is as described above, and it will not be repeated here.
  • S302 Generate a link of the first JS mining script and a link of the second JS mining script.
  • the terminal may generate a link of the first JS mining script and a link of the second JS mining script according to the first JS mining script and the second JS mining script included in the JS mining script library.
  • S303 Embed the link of the first JS mining script in the second location area of the target webpage, and embed the link of the second JS mining script in the third location area of the target webpage.
  • the terminal may embed the link of the first JS mining script in the second location area of the target webpage, and embed the link of the second JS mining script in the target webpage.
  • the third position area The explanation of the second location area and the third location area is as described above, and is not repeated here. For example, assuming that the second location area is the comment location area on the target web page and the third location area is the image display location area on the target web page, the terminal may embed the link of the first JS mining script in the target web page. A review location area, and an image display location area where the link of the second JS mining script is embedded in the target webpage.
  • step S304 When the start instruction of the link of the first JS mining script is detected, the terminal that accesses the target webpage is triggered to determine whether the browser version number used by the terminal that accesses the target webpage is any one of a set of preset version numbers. In other words, if the determination result is yes, step S305 is performed, and if the determination result is no, step S306 is performed.
  • a terminal that accesses the target webpage is triggered to determine whether a browser version number used by the terminal that accesses the target webpage is a pre- If any one of the version number sets is determined, if it is determined that the browser version number used by the terminal accessing the target webpage is any one of the preset version number sets, step S305 is performed. If it is determined that the version number of the browser used by the terminal accessing the target webpage is not any one of a set of preset version numbers, step S306 is performed.
  • the terminal that triggers the terminal that accesses the target webpage to determine whether the browser version number used by the terminal that accesses the target webpage is any one of a set of preset version numbers, and the specific implementation process and examples are as described above, here No longer.
  • a terminal that accesses the target webpage is judged to determine a browser version number used by a terminal that accesses the target webpage Whether it is any of the preset version number set.
  • a start instruction of a link of a second JS mining script embedded in an image location area of a target webpage is detected, a terminal that accesses the target webpage is judged to determine a browser version used by a terminal that accesses the target webpage. Whether the number is any one of a set of preset version numbers.
  • S305 Determine that the browser used by the terminal accessing the target webpage supports the WebAssembly language, and trigger the browser used by the terminal accessing the target webpage to load and execute the first JS mining script.
  • the browser version number used by the terminal accessing the target webpage is any one of a set of preset version numbers
  • the specific implementation process and examples of triggering the browser used by the terminal that accesses the target webpage to load and execute the first JS mining script are as described above, and are not repeated here.
  • the browser used by the terminal of the target web page does not support the WebAssembly language, and triggers the browser used by the terminal accessing the target web page to load and execute the second JS mining script.
  • the specific implementation process and the example of triggering the second JS mining script to be loaded and executed by the browser used by the terminal that accesses the target webpage are described above, and are not repeated here.
  • the terminal may embed the generated link of the first JS mining script in the second location area of the target webpage, and embed the generated link of the second JS mining script in the third location area of the target webpage.
  • the browser used by the terminal accessing the target webpage is called to load and execute the first JS according to the version number of the browser used by the terminal accessing the target webpage.
  • Mining script or second JS mining script In this way, the CPU resources of the terminal accessing the target webpage can be consumed in large quantities to achieve the purpose of anti-crawling, further improving the efficiency and effectiveness of anti-crawling, thereby enhancing the security of the Internet.
  • FIG. 4 is a schematic block diagram of a terminal provided by an embodiment of the present application.
  • the terminal in this embodiment includes: an obtaining unit 401, an embedding unit 402, and a triggering unit 403.
  • the obtaining unit 401 is configured to obtain a JS mining script library, where the JS mining script library includes at least one JS mining script.
  • the obtaining unit 401 is specifically configured to establish the JS mining script library, where the JS mining script library includes a first JS mining script and a second JS mining script; wherein the first JS mining script The script is a script of the WebAssembly language, and the second JS mining script is a script of the JS language.
  • the embedding unit 402 is configured to generate a link of the at least one JS mining script, and embed the link of the at least one JS mining script in a target webpage.
  • the embedding unit 402 is specifically configured to determine a first location area according to a probability that data information of each location area in the target webpage is crawled in the history record, and the first location area is each location in the target webpage.
  • the data information of the area is crawled in the location area with the highest probability; the link of the at least one JS mining script is embedded in the first location area of the target webpage.
  • the embedding unit 402 is specifically configured to generate a link of the first JS mining script and a link of the second JS mining script; according to the history, the target webpage is supported by the WebAssembly language.
  • the probability that the browser crawls the data information of each location area determines the second location area, where the second location area is the location where the data information of each location area in the target webpage is most likely to be crawled by a browser that supports the WebAssembly language
  • a third location area according to a probability that a browser that does not support the WebAssembly language crawls data information of each location area in the target webpage in the history record, and the third location area is each of the target webpages
  • the location information has the highest probability of being crawled by a browser that does not support the WebAssembly language; embed the link of the first JS mining script into the second location area of the target webpage, and The link of the second JS mining script is embedded in the third location area of the target webpage.
  • a triggering unit 403 is configured to trigger a terminal accessing the target webpage to load and execute the at least one JS mining script when a start instruction of the link of the at least one JS mining script is detected.
  • a triggering unit 403 is configured to trigger a terminal that accesses the target webpage to select a target according to a language supported by a browser used by the terminal when a start instruction of a link of the at least one JS mining script is detected.
  • the first JS mining script or the second JS mining script is described; a browser used by the terminal is called to load and execute the first JS mining script or the second JS mining script selected by the terminal.
  • a triggering unit 403 is configured to trigger a terminal accessing the target webpage to determine whether a browser version number used by the terminal is any one of a preset version number set; if the determination result is yes, determine the The browser used by the terminal supports the WebAssembly language, and the first JS mining script is selected from the JS mining script library; if the result of the judgment is no, it is determined that the browser used by the terminal does not support the WebAssembly language.
  • the second JS mining script is selected from the JS mining script library.
  • a triggering unit 403 is configured to trigger a terminal accessing the target webpage to determine whether a version number of a browser used by the terminal is a preset version when a start instruction of a link of the first JS mining script is detected. Any one of the set of IDs; if the judgment result is yes, it is determined that the browser used by the terminal supports the WebAssembly language, and triggers the browser used by the terminal accessing the target webpage to load and execute the first JS Mining script; if the result of the judgment is no, when the start instruction of the link of the second JS mining script is detected, it is determined that the browser used by the terminal does not support the WebAssembly language and triggers access to the target The browser used by the terminal of the webpage loads and executes the second JS mining script.
  • the obtaining unit 401 of the terminal may generate a link of the at least one JS mining script
  • the embedding unit 402 embeds the link of the at least one JS mining script into a target webpage
  • the triggering unit 403 When the start instruction of the link of at least one JS mining script is described, a terminal accessing the target webpage is triggered to load and execute the at least one JS mining script, thereby preventing a crawler terminal from bypassing JS rendering and crawling data, and improving anti-crawling Effectiveness.
  • FIG. 5 is a schematic block diagram of another terminal provided by an embodiment of the present application.
  • the terminal in this embodiment as shown in the figure may include: one or more processors 501; one or more input devices 502, one or more output devices 503, and a memory 504.
  • the processor 501, the input device 402, the output device 503, and the memory 504 are connected through a bus 505.
  • the memory 504 is configured to store a computer program, where the computer program includes program instructions, and the processor 501 is configured to execute the program instructions stored in the memory 504.
  • the processor 501 is configured to call the program instruction to execute:
  • JS mining script library includes at least one JS mining script
  • a terminal that accesses the target webpage is triggered to load and execute the at least one JS mining script.
  • processor 501 is configured to perform the following steps:
  • the JS mining script library includes a first JS mining script and a second JS mining script
  • the first JS mining script is a script of the WebAssembly language
  • the second JS mining script is a script of the JS language.
  • processor 501 is configured to perform the following steps:
  • a first location area is determined according to a probability that data information of each location area in the target webpage is crawled in the history record, and the first location area is a data area with the highest probability of being crawled Location area
  • processor 501 is configured to perform the following steps:
  • a terminal that triggers access to the target webpage selects the first JS mining script or the first JS mining script according to a language supported by the browser used by the terminal.
  • the browser used by the terminal is called to load and execute the first JS mining script or the second JS mining script selected by the terminal.
  • processor 501 is configured to perform the following steps:
  • the second JS mining script is selected from the JS mining script library.
  • processor 501 is configured to perform the following steps:
  • Determining a second location area according to a probability that the WebAssembly language-supported browser crawls data information of each location area in the target webpage in the history record, where the second location area is a A location region where the data information is crawled with the greatest probability by a browser supporting the WebAssembly language;
  • processor 501 is configured to perform the following steps:
  • a terminal that triggers access to the target webpage to determine whether the browser version number used by the terminal is any one of a set of preset version numbers
  • the determination result is yes, determining that the browser used by the terminal supports the WebAssembly language, and triggering the browser used by the terminal accessing the target webpage to load and execute the first JS mining script;
  • the terminal when the terminal detects the start instruction of the link of the at least one JS mining script, the terminal that accesses the target webpage is triggered to load and execute the at least one JS mining script, thereby consuming a large amount of crawlers.
  • the CPU resources of the terminal prevent the crawler terminal from being used normally to achieve the purpose of anti-crawling, and can prevent the crawler terminal from bypassing JS rendering and crawling data, which improves the effectiveness of anti-crawling.
  • the processor 501, the input device 502, and the output device 503 described in the embodiments of the present application may execute the anti-crawler method provided in the embodiments of the present application in the method embodiments shown in FIG. 1, FIG. 2, or FIG. 3.
  • the described implementation manner may also implement the implementation manner of the terminal described in FIG. 4 in the embodiment of the present application, and details are not described herein again.
  • a computer-readable storage medium is also provided in the embodiment of the present application.
  • the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the embodiments corresponding to FIG. 1, FIG. 2, or FIG. 3.
  • the anti-crawler method described in the above can also implement the terminal of the embodiment corresponding to FIG. 4 or FIG. 5 of the present application, and details are not described herein again.
  • the computer-readable storage medium may be an internal storage unit of the terminal according to any of the foregoing embodiments, such as a hard disk or a memory of the terminal.
  • the computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a Smart Media Card (SMC), and a Secure Digital (SD) card provided on the terminal. , Flash card (Flash card) and so on.
  • the computer-readable storage medium may further include both an internal storage unit of the terminal and an external storage device.
  • the computer-readable storage medium is used to store the computer program and other programs and data required by the terminal.
  • the computer-readable storage medium may also be used to temporarily store data that has been or will be output.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种反爬虫方法、终端及计算机可读存储介质,其中方法包括:获取JS挖矿脚本库(S101),所述JS挖矿脚本库包括至少一个JS挖矿脚本;生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页(S102);当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本(S103)。上述方法可以大量消耗爬虫终端的CPU资源,使爬虫终端无法正常使用,以达到反爬的目的,以及可以防止爬虫终端绕过JS渲染爬取数据,提高了反爬的有效性。

Description

一种反爬虫方法、终端及计算机可读存储介质
本申请要求于2018年06月27日提交中国专利局、申请号为201810685659.3、申请名称为“一种反爬虫方法、终端及计算机可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信技术领域,尤其涉及一种反爬虫方法、终端及计算机可读存储介质。
背景技术
目前互联网上的爬虫主要分为静态爬虫和动态爬虫,由于静态爬虫不能解析JavaScript(简称JS)代码,因此对于静态爬虫的应对方法通常是采用通过在网页中添加JS代码,以对网页进行JS渲染处理的方式来达到反爬的目的。然而这种对网页进行JS渲染处理的方式对于能够解析JS的动态爬虫不能达到反爬虫的目的。因此,如何更有效地阻止爬虫的影响,提高互联网的安全成为研究的热点。
发明内容
本申请实施例提供一种反爬虫方法、终端及计算机可读存储介质,可提高反爬的有效性,提高互联网安全性。
第一方面,本申请实施例提供了一种反爬虫方法,该方法包括:
获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本;
生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页;
当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
第二方面,本申请实施例提供了一种终端,该终端包括用于执行上述第一方面的方法的单元。
第三方面,本申请实施例提供了另一种终端,包括处理器、输入设备、输出设备和存储器,所述处理器、输入设备、输出设备和存储器相互连接,其中,所述存储器用于存储支持终端执行上述方法的计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行上述第一方面的方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述第一方面的方法。
本申请实施例,当检测到嵌入目标网页的JS挖矿脚本的链接的启动指令时,触发访问该目标网页的终端加载并执行该JS挖矿脚本,防止了爬虫终端绕过JS渲染爬取数据,提高了反爬的有效性。
附图说明
图1是本申请实施例提供的一种反爬虫方法的示意流程图;
图2是本申请实施例提供的另一种反爬虫方法的示意流程图;
图3是本申请实施例提供的又一种反爬虫方法的示意流程图;
图4是本申请实施例提供的一种终端的示意框图;
图5是本申请实施例提供的另一种终端示意框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供的反爬虫方法可以由终端执行,所述终端可以是手机、电脑、平板、智能手表等智能终端上。下面对应用于终端的反爬虫方法进行举例说明。
本方案是针对能够解析JS的动态爬虫所做的反爬虫技术方案,现有技术中关于网页的常用反爬虫策略通常为在网页中添加JS代码来进行JS渲染处理,以实现对静态爬虫进行反爬,然而这种方式对于能够解析JS的动态爬虫而言,不能达到反爬虫的目的,因此本方案针对能够解析JS的动态爬虫对反爬虫策略进行了改进。
在介绍本方案之前,首先介绍一下能够解析JS的动态爬虫。能够解析JS的动态爬虫的爬虫过程有两种情况:一种是通过直接对html源码进行解析;另外还有一种特殊情况是:如果网页的数据是采用异步加载的,比如ajax加载的数据,则能够解析JS的动态爬虫无法解析并查看源代码,针对这种特殊情况,能够解析JS的动态爬虫常采用一些第三方的工具比如:支持WebAssembly语言的浏览器中的自动测试工具Selenium或者配合无界面浏览器PhantomJs,模拟浏览器的行为去加载数据。需要说明的是,该WebAssembly是一种运行在现代网络浏览器中的一种网页汇编语言,文件后缀为“.wasm”。
因此,本方案针对能够解析JS的动态爬虫在爬虫过程中所使用的上述两种爬虫方式,预先编写了至少一个JS挖矿脚本,并建立JS挖矿脚本库,根据该JS挖矿脚本库中预先编写的至少一个JS挖矿脚本,生成至少一个JS挖矿脚本的链接。本申请实施例将生成的该至少一个JS挖矿脚本的链接嵌入目标 网页中数据信息被爬取的概率较高的位置区域,如果检测到访问该目标网页的终端打开嵌入该目标网页中的所述至少一个JS挖矿脚本的链接,则确定访问该目标网页的终端为爬虫终端,并触发访问该目标网页的终端自动加载和执行所述链接中的至少一个JS挖矿脚本,以达到反爬的目的。下面结合附图对本申请实施例进行详细说明。
参见图1,图1是本申请实施例提供的一种反爬虫方法的示意流程图,如图1所示,该方法可以由终端执行,所述终端的具体解释如前所述,此处不再赘述。具体地,本申请实施例的所述方法包括如下步骤。
S101:获取JS挖矿脚本库。
本申请实施例中,终端可以建立JS挖矿脚本库,其中,该终端所建立的JS挖矿脚本库中包括一个或多个JS挖矿脚本。
在一个实施例中,该终端建立的JS挖矿脚本库中包括第一JS挖矿脚本和第二JS挖矿脚本。其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
其中,所述第一JS挖矿脚本是根据WebAssembly语言编写的脚本,在一个实施例中,由于通常情况下能够解析JS的动态爬虫常使用Selenium配合Webdriver调用浏览器来模拟浏览器操作,其中,使用Selenium配合Webdriver调用的浏览器是支持该WebAssembly的浏览器;或者使用Selenium配合PhantomJS这种无界面的浏览器来模拟浏览器操作。因此本方案针对能够解析JS的动态爬虫常使用的支持该WebAssembly的浏览器或者PhantomJS,利用WebAssembly语言编写了所述第一JS挖矿脚本。
在其他实施例中,所述第二JS挖矿脚本是JS语言的脚本,由于能够解析JS的动态爬虫还可以使用不支持WebAssembly的普通浏览器直接解析html源码进行解析,因此利用JS语言编写了第二JS挖矿脚本。
S102:生成至少一个JS挖矿脚本的链接,将至少一个JS挖矿脚本的链接嵌入目标网页。
本申请实施例中,终端可以生成至少一个JS挖矿脚本的链接,并将所述至少一个JS挖矿脚本的链接嵌入目标网页。
在一个实施例中,该终端可以根据由第一JS挖矿脚本和第二JS挖矿脚本建立的JS挖矿脚本库生成至少一个JS挖矿脚本的链接,并将所述至少一个JS挖矿脚本的连接嵌入目标网页的第一位置区域。
其中,所述第一位置区域是根据历史记录中记录的所述目标网页中各位置区域的数据信息被爬取的概率确定的,如果从所述目标网页的各位置区域中确定出某位置区域的数据信息被爬取的概率最大,则确定所述数据信息被爬取概率最大的位置区域为第一位置区域。例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了评论位 置区域的数据信息被爬取的概率为90%,提问位置区域的数据信息被爬取的概率为60%,图像显示位置区域的数据信息被爬取的概率为20%,信息显示位置区域的数据信息被爬取的概率为50%,将各位置区域的数据信息被爬取的概率进行对比,确定所述评论位置区域的数据信息被爬取的概率90%最大,因此确定所述目标网页中的评论位置区域为第一位置区域。
在一个实施例中,所述第一位置区域可以根据历史记录中记录的所述目标网页中各位置区域的数据信息被爬取的关键字确定得到,如果从所述目标网页的各位置区域中确定出某位置区域中包括的数据信息被爬取的关键字最多,则确定该位置区域为第一位置区域。例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了评论位置区域的数据信息被爬取的关键字数量为n,提问位置区域的数据信息被爬取的关键字数量为m,图像显示位置区域的数据信息被爬取的关键字数量为x,信息显示位置区域的数据信息被爬取的关键字数量为y,将各位置区域的数据信息被爬取的关键字数量进行对比,如果n>m>x>y,则可以确定所述评论位置区域的数据信息被爬取的关键字数量最多,因此确定所述目标网页中的评论位置区域为第一位置区域。
通过该实施方式,在检测到访问该目标网页的终端为爬虫终端时,可以确定该爬虫终端最大概率会爬取该目标网页的第一位置区域的数据信息,从而提高该爬虫终端打开该第一位置区域的至少一个JS挖矿脚本的链接的效率,以提高反爬的效率。
在一个实施例中,该终端可以根据获取到的第一JS挖矿脚本生成第一挖矿脚本的链接,以及根据获取到的第二JS挖矿脚本生成第二挖矿脚本的链接,并将该第一JS挖矿脚本的链接嵌入目标网页的第二位置区域,以及将第二JS挖矿脚本的链接嵌入目标网页的第三位置区域。
其中,所述第二位置区域是根据历史记录中记录的所述目标网页中被支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定的,如果从所述目标网页的各位置区域中确定出某位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率最大,则确定所述被支持所述WebAssembly语言的浏览器爬取的概率最大的位置区域为第二位置区域。
例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了评论位置区域和提问位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取,且所述评论位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率为80%,所述提问位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率为50%,将所述评论位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率与所述提问位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率进行对比,确定所述评论位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率80%最大,因此确定所述目标网页中的评 论位置区域为所述第二位置区域。
在一个实施例中,所述第二位置区域可以是根据历史记录中记录的所述目标网页中各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字确定的,如果从所述目标网页的各位置区域中确定出某位置区域中包括的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字最多,则确定该位置区域为第二位置区域。
例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了评论位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量为n,提问位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量为m,图像显示位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量为x,信息显示位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量为y,将各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量进行对比,如果n>m>x>y,则可以确定所述评论位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量最多,因此确定所述目标网页中的评论位置区域为第二位置区域。
在一个实施例中,所述第三位置区域是根据历史记录中记录的所述目标网页中被不支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定的,如果从所述目标网页的各位置区域中确定出某位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的概率最大,则确定所述被不支持所述WebAssembly语言的浏览器爬取的概率最大的位置区域为第三位置区域。
例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了图像显示位置区域和信息显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取,且所述图像显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的概率为60%,所述信息显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的概率为90%,将所述图像显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的概率与所述信息显示位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的概率进行对比,确定所述信息显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的概率90%最大,因此确定所述目标网页中的信息显示位置区域为所述第三位置区域。
在一个实施例中,所述第三位置区域还可以是根据历史记录中记录的所述目标网页中各位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字确定的,如果从所述目标网页的各位置区域中确定出某位置区域中包括的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字最多,则确定该位置区域为第三位置区域。
例如,假设所述目标网页中包括评论位置区域、提问位置区域、图像显示位置区域、信息显示位置区域,如果获取到历史记录中记录了评论位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字数量为n,提问位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字数量为m,图像显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字数量为x,信息显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字数量为y,将各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取的关键字数量进行对比,如果n<m<x<y,则可以确定所述信息显示位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取的关键字数量最多,因此确定所述目标网页中的信息显示位置区域为所述第三位置区域。
通过该实施方式,在检测到访问该目标网页的终端为爬虫终端时,如果访问该目标网页的终端使用的浏览器支持WebAssembly,则可以确定该爬虫终端最大概率会先爬取该目标网页的第二位置区域的数据信息。如果访问该目标网页的终端使用的浏览器不支持WebAssembly,则可以确定该爬虫终端最大概率会先爬取该目标网页的第三位置区域的数据信息。因此根据访问该目标网页的终端使用的浏览器所支持的语言,访问该目标网页的终端最大概率会加载并执行与该爬虫终端使用的浏览器所支持的语言对应的JS挖矿脚本的链接,从而进一步提高了反爬的效率和有效性。
在一个实施例中,该终端在将至少一个JS挖矿脚本的链接嵌入目标网页时,可以在该至少一个JS挖矿脚本的链接上添加提示信息,以提醒访问该目标网页的正常用户不要点击此链接,并将添加提示信息的该至少一个JS挖矿脚本的链接嵌入该目标网页的任意位置区域。
例如,如果该终端将至少一个JS挖矿脚本的链接嵌入目标网页,则可以在至少一个JS挖矿脚本的链接上添加“请勿点击”的提示信息,然后将添加该提示信息的至少一个JS挖矿脚本的链接嵌入到该目标网页上的第一位置区域,其中所述目标位位置区域的解释如前所述,此处不再赘述。
又例如,如果该终端分别将第一JS挖矿脚本的链接嵌入目标网页的第二位置区域,以及将第二JS挖矿脚本的链接嵌入目标网页的第三位置区域,则可以在该第一JS挖矿脚本的链接和该第二JS挖矿脚本的链接上添加“请勿点击”的提示信息,然后分别将添加该提示信息的第一JS挖矿脚本的链接嵌入到该目标网页上的第二位置区域,以及将添加该提示信息的第二JS挖矿脚本的链接嵌入到该目标网页上的第三位置区域,其中,所述第二位置区域和第三位置区域的解释如前所述,此处不再赘述。
通过该实施方式可以在一定程度上避免访问该目标网页的正常终端的用户不小心点击到嵌入该目标网页的所述至少一个JS挖矿脚本的链接,从而避免对访问该目标网页的正常终端造成损害。
S103:当检测到至少一个JS挖矿脚本的链接的启动指令时,触发访问目标网页的终端加载并执行所述至少一个JS挖矿脚本。
本申请实施例中,在检测到有终端访问该目标网页,如果检测到嵌入该目标网页的至少一个JS挖矿脚本的链接被打开,则确定访问该目标网页的终端为爬虫终端,并触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本,以大量消耗访问所述目标网页的终端的CPU资源,到达反爬的目的,并防止了该终端绕过JS渲染爬取该目标网页的数据信息,从而提高反爬的有效性以及增强了互联网的安全。
本申请实施例中,终端可以通过将至少一个JS挖矿脚本的链接嵌入目标网页,当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行至少一个JS挖矿脚本,从而防止该访问所述目标网页的终端绕过JS渲染爬取数据,提高了反爬的有效性。
参见图2,图2是本申请实施例提供的另一种反爬虫方法的示意流程图,如图2所示,该方法可以由终端执行,该终端的具体解释如前所述,此处不再赘述。具体地,本申请实施例的所述方法包括如下步骤。
S201:获取JS挖矿脚本库。
本申请实施例中,终端可以建立JS挖矿脚本库,该JS挖矿脚本库中包括第一JS挖矿脚本和第二JS挖矿脚本。其中,所述第一JS挖矿脚本和第二JS挖矿脚本的解释如前所述,此处不再赘述。
S202:生成至少一个JS挖矿脚本的链接,将至少一个JS挖矿脚本的链接嵌入目标网页的第一位置区域。
本申请实施例中,终端可以根据获取到的JS挖矿脚本库生成该至少一个JS挖矿脚本的链接,并将该至少一个JS挖矿脚本的链接嵌入到目标网页的标位置区域。其中,所述第一位置区域的具体如前所述,此处不再赘述。
S203:当检测到至少一个JS挖矿脚本的链接的启动指令时,触发访问该目标网页的终端根据访问该目标网页的终端使用的浏览器所支持的语言,选取第一JS挖矿脚本或第二JS挖矿脚本。
本申请实施例中,终端可以在检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据访问该目标网页的终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本。
其中,访问目标网页的终端可以根据访问该目标网页的终端所使用的浏览的版本号来判断访问该目标网页的终端所使用的浏览器是否支持WebAssembly语言语言。在一个实施例中,在检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断访问该目标网页的终端使用的浏览器版本号是否为预设版本号集合中的任意一种。如果判断出访问该目标网页的终端使用的浏览器版本号为预设版本号集合中的任意一种,则确定访问该目标网页的终端使用的浏览器支持WebAssembly 语言,因此从该JS挖矿脚本库中选取第一JS挖矿脚本。如果判断出访问该目标网页的终端使用的浏览器版本号不是预设版本号集合中的任意一种,则确定访问该目标网页的终端使用的浏览器不支持WebAssembly语言,从而从该JS挖矿脚本库中选取第二JS挖矿脚本。
例如,假设预设版本号集合为{Firefox1.0、Firefox9、Firefox8、Firefox7、Firefox6、Firefox5、Firefox4、Firefox3.6、Firefox3、IE9、IE8、IE7},当检测到至少一个JS挖矿脚本的链接的启动指令时,触发访问目标网页的终端判断该访问目标网页的终端所使用的浏览器版本号是否为预设版本号集合中的任意一种,如果判断出访问目标网页的终端所使用的浏览器版本号为IE8,则可以确定该访问目标网页的终端使用的浏览器为预设版本号集合中的一种,因此该访问目标网页的终端使用的浏览器支持WebAssembly语言,从该JS挖矿脚本库中选取第一JS挖矿脚本。
又例如,假设预设版本号集合为{Firefox1.0、Firefox9、Firefox8、Firefox7、Firefox6、Firefox5、Firefox4、Firefox3.6、Firefox3、IE9、IE8、IE7},当检测到至少一个JS挖矿脚本的链接的启动指令时,触发访问目标网页的终端判断该访问目标网页的终端所使用的浏览器版本号是否为预设版本号集合中的任意一种,如果判断出访问目标网页的终端所使用的浏览器版本号为IE5,则可以确定该访问目标网页的终端使用的浏览器不是预设版本号集合中的任意一种,因此该访问目标网页的终端使用的浏览器不支持WebAssembly语言,从该JS挖矿脚本库中选取第一JS挖矿脚本。
S204:调用访问该目标网页的终端使用的浏览器加载并执行第一JS挖矿脚本或第二JS挖矿脚本。
本申请实施例中,终端可以调用访问目标网页的终端使用的浏览器加载并执行访问所述目标网页的终端速选取的第一JS挖矿脚本或第二JS挖矿脚本。
在一个实施例中,如果检测到访问所述目标网页的终端从JS挖矿脚本库中选取的脚本是第一JS挖矿脚本,则终端可以调用访问所述目标网页的终端所使用的浏览器加载并执行该第一JS挖矿脚本。例如,如果检测到访问所述目标网页的终端从JS挖矿脚本库中选取的脚本是第一JS挖矿脚本,假设确定出访问所述目标网页的终端所使用的浏览器为IE8,则可以调用访问该目标网页的终端所使用的浏览器IE8加载并执行该第一JS挖矿脚本。
在一个实施例中,如果检测到访问目标网页的终端从JS挖矿脚本库中选取的脚本是第二JS挖矿脚本,则终端可以调用访问所述目标网页的终端所使用的不支持WebAssembly语言的浏览器加载并执行该第二JS挖矿脚本。例如,如果检测到访问目标网页的终端从JS挖矿脚本库中选取的脚本是第二JS挖矿脚本,假设确定出访问所述目标网页的终端所使用的浏览器为IE5,则可以调用访问该目标网页的终端所使用的浏览器IE5加载并执行该第二JS挖矿脚本。
本申请实施例中,终端可以在检测到至少一个JS挖矿脚本的链接的启动指令时,触发访问该目标 网页的终端根据访问该目标网页的终端所使用的浏览器支持的语言,选取第一JS挖矿脚本或第二JS挖矿脚本,并调用访问目标网页的终端使用的浏览器加载并执行访问该目标网页的终端选取的第一JS挖矿脚本或第二JS挖矿脚本,以消耗访问该目标网页的终端的CPU资源,达到反爬的目的,提高反爬的有效性。
参见图3,图3是本申请实施例提供的又一种反爬虫方法的示意流程图,如图3所示,该方法可以由终端执行,该终端的具体解释如前所述,此处不再赘述。具体地,本申请实施例的所述方法包括如下步骤。
S301:获取JS挖矿脚本库,该JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本。
本申请实施例中,终端可以获取JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本,所述第一JS挖矿脚本和第二JS挖矿脚本的解释如前所述,此处不再赘述。
S302:生成第一JS挖矿脚本的链接和第二JS挖矿脚本的链接。
本申请实施例中,终端可以根据该JS挖矿脚本库中包括的第一JS挖矿脚本和第二JS挖矿脚本,生成第一JS挖矿脚本的链接和第二JS挖矿脚本的链接。
S303:将该第一JS挖矿脚本的链接嵌入该目标网页的第二位置区域,以及将该第二JS挖矿脚本的链接嵌入该目标网页的第三位置区域。
本申请实施例中,终端可以将所述第一JS挖矿脚本的链接嵌入所述目标网页的所述第二位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的所述第三位置区域。其中,所述第二位置区域和第三位置区域的解释如前所述,此处不再赘述。例如,假设第二位置区域为目标网页中的评论位置区域,第三位置区域为目标网页中的图像显示位置区域,则终端可以将所述第一JS挖矿脚本的链接嵌入所述目标网页的评论位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的图像显示位置区域。
S304:当检测到该第一JS挖矿脚本的链接的启动指令时,触发访问该目标网页的终端判断访问该目标网页的终端使用的浏览器版本号是否为预设版本号集合中的任意一种,如果判断结果为是,则执行步骤S305,如果判断结果为否,则执行步骤S306。
本申请实施例中,当检测到所述第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断访问所述目标网页的终端所使用的浏览器版本号是否为预设版本号集合中的任意一种,如果判断出访问该目标网页的终端使用的浏览器版本号为预设版本号集合中的任意一种,则执行步骤S305。如果判断出访问该目标网页的终端使用的浏览器版本号不是预设版本号集合中的任意一种,则执行步骤S306。其中,触发访问所述目标网页的终端判断访问所述目标网页的终端所使用的浏览器版本号是否为 预设版本号集合中的任意一种的具体实施过程和举例如前所述,此处不再赘述。
例如,当检测到嵌入到目标网页中评论位置区域的第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断访问所述目标网页的终端所使用的浏览器版本号是否为预设版本号集合中的任意一种。又例如,当检测到嵌入到目标网页中图像位置区域的第二JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断访问所述目标网页的终端所使用的浏览器版本号是否为预设版本号集合中的任意一种。
S305:确定访问该目标网页的终端使用的浏览器支持WebAssembly语言,并触发访问该目标网页的终端使用的浏览器加载并执行该第一JS挖矿脚本。
本申请实施例中,如果判断出访问该目标网页的终端使用的浏览器版本号为预设版本号集合中的任意一种,则确定访问所述目标网页的终端使用的浏览器支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本。其中,触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本的具体实施过程以及举例说明如前所述,此处不再赘述。
S306:在检测到第二JS挖矿脚本的链接的启动指令时,触发访问该目标网页的终端使用的浏览器加载并执行该第二JS挖矿脚本。
本申请实施例中,如果判断出该终端使用的浏览器版本号不是预设版本号集合中的任意一种,则在检测到所述第二JS挖矿脚本的链接的启动指令时,确定访问所述目标网页的终端使用的浏览器不支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本。其中,触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本的具体实施过程以及举例说明如前所述,此处不再赘述。
本申请实施例中,终端可以将生成的第一JS挖矿脚本的链接嵌入目标网页的第二位置区域,以及将生成的第二JS挖矿脚本的链接嵌入目标网页的第三位置区域,当检测到第一JS挖矿脚本的链接的启动指令时,根据访问所述目标网页的终端所使用的浏览器版本号,调用访问所述目标网页的终端所使用的浏览器加载并执行第一JS挖矿脚本或第二JS挖矿脚本。通过这种方式可以大量消耗访问目标网页的终端的CPU资源,达到反爬的目的,进一步提高了反爬的效率和有效性,从而增强了互联网的安全性。
本申请实施例还提供了一种终端,该终端用于执行前述任一项所述的方法的单元。具体地,参见图4,图4是本申请实施例提供的一种终端的示意框图。本实施例的终端包括:获取单元401、嵌入单元402、触发单元403。
获取单元401,用于获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本。
进一步地,获取单元401,具体用于建立所述JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿 脚本和第二JS挖矿脚本;其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
嵌入单元402,用于生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页。
进一步地,嵌入单元402,具体用于根据历史记录中所述目标网页中各位置区域的数据信息被爬取的概率确定第一位置区域,所述第一位置区域是所述目标网页中各位置区域的数据信息被爬取概率最大的位置区域;将所述至少一个JS挖矿脚本的链接嵌入所述目标网页的所述第一位置区域。
进一步地,嵌入单元402,具体用于生成所述第一JS挖矿脚本的链接和所述第二JS挖矿脚本的链接;根据历史记录中所述目标网页中被支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第二位置区域,所述第二位置区域是所述目标网页中各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;根据历史记录中所述目标网页中被不支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第三位置区域,所述第三位置区域是所述目标网页中各位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;将所述第一JS挖矿脚本的链接嵌入所述目标网页的所述第二位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的所述第三位置区域。
触发单元403,用于当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
进一步地,触发单元403,用于当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本;调用所述终端使用的浏览器加载并执行所述终端选取的所述第一JS挖矿脚本或第二JS挖矿脚本。
进一步地,触发单元403,用于触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;如果判断结果为是,则确定所述终端使用的浏览器支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第一JS挖矿脚本;如果判断结果为否,则确定所述终端使用的浏览器不支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第二JS挖矿脚本。
进一步地,触发单元403,用于当检测到所述第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;如果判断结果为是,则确定所述终端使用的浏览器支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本;如果判断结果为否,则在检测到所述第二JS挖矿脚本的 链接的启动指令时,确定所述终端使用的浏览器不支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本。
本申请实施例中,终端的获取单元401可以通过生成所述至少一个JS挖矿脚本的链接,嵌入单元402将所述至少一个JS挖矿脚本的链接嵌入目标网页,触发单元403当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本,从而防止爬虫终端绕过JS渲染爬取数据,提高了反爬的有效性。
参见图5,图5是本申请实施例提供的另一种终端示意框图。如图所示的本实施例中的终端可以包括:一个或多个处理器501;一个或多个输入设备502,一个或多个输出设备503和存储器504。上述处理器501、输入设备402、输出设备503和存储器504通过总线505连接。存储器504用于存储计算机程序,所述计算机程序包括程序指令,处理器501用于执行存储器504存储的程序指令。其中,处理器501被配置用于调用所述程序指令执行:
获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本;
生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页;
当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
进一步地,所述处理器501用于执行如下步骤:
建立所述JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本;
其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
进一步地,所述处理器501用于执行如下步骤:
根据历史记录中所述目标网页中各位置区域的数据信息被爬取的概率确定第一位置区域,所述第一位置区域是所述目标网页中各位置区域的数据信息被爬取概率最大的位置区域;
将所述至少一个JS挖矿脚本的链接嵌入所述目标网页的所述第一位置区域。
进一步地,所述处理器501用于执行如下步骤:
当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本;
调用所述终端使用的浏览器加载并执行所述终端选取的所述第一JS挖矿脚本或第二JS挖矿脚本。
进一步地,所述处理器501用于执行如下步骤:
触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
如果判断结果为是,则确定所述终端使用的浏览器支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第一JS挖矿脚本;
如果判断结果为否,则确定所述终端使用的浏览器不支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第二JS挖矿脚本。
进一步地,所述处理器501用于执行如下步骤:
生成所述第一JS挖矿脚本的链接和所述第二JS挖矿脚本的链接;
根据历史记录中所述目标网页中被支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第二位置区域,所述第二位置区域是所述目标网页中各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
根据历史记录中所述目标网页中被不支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第三位置区域,所述第三位置区域是所述目标网页中各位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
将所述第一JS挖矿脚本的链接嵌入所述目标网页的所述第二位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的所述第三位置区域。
进一步地,所述处理器501用于执行如下步骤:
当检测到所述第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
如果判断结果为是,则确定所述终端使用的浏览器支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本;
如果判断结果为否,则在检测到所述第二JS挖矿脚本的链接的启动指令时,确定所述终端使用的浏览器不支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本。
本申请实施例中,终端可以在检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本,从而大量消耗爬虫终端的CPU资源,使爬虫终端无法正常使用,以达到反爬的目的,以及可以防止爬虫终端绕过JS渲染爬取数据,提高了反爬的有效性。
具体实现中,本申请实施例中所描述的处理器501、输入设备502、输出设备503可执行本申请实施例提供的反爬虫方法的图1、图2或图3所述的方法实施例中所描述的实现方式,也可执行本申请实施例图4所描述的终端的实现方式,在此不再赘述。
本申请实施例中还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现图1、图2或图3所对应实施例中描述的反爬虫方法,也可实现本申请图4或图5所对应实施例的终端,在此不再赘述。
所述计算机可读存储介质可以是前述任一实施例所述的终端的内部存储单元,例如终端的硬盘或内存。所述计算机可读存储介质也可以是所述终端的外部存储设备,例如所述终端上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述计算机可读存储介质还可以既包括所述终端的内部存储单元也包括外部存储设备。所述计算机可读存储介质用于存储所述计算机程序以及所述终端所需的其他程序和数据。所述计算机可读存储介质还可以用于暂时地存储已经输出或者将要输出的数据。
以上所述,仅为本申请的部分实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。

Claims (20)

  1. 一种反爬虫方法,其特征在于,包括:
    获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本;
    生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页;
    当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
  2. 根据权利要求1所述的方法,其特征在于,所述获取JS挖矿脚本库,包括:
    建立所述JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本;
    其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
  3. 根据权利要求1所述的方法,其特征在于,所述将所述至少一个JS挖矿脚本的链接嵌入目标网页,包括:
    根据历史记录中所述目标网页中各位置区域的数据信息被爬取的概率确定第一位置区域,所述第一位置区域是所述目标网页中各位置区域的数据信息被爬取概率最大的位置区域;
    将所述至少一个JS挖矿脚本的链接嵌入所述目标网页的所述第一位置区域。
  4. 根据权利要求2所述的方法,其特征在于,所述当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本,包括:
    当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本;
    调用所述终端使用的浏览器加载并执行所述终端选取的所述第一JS挖矿脚本或第二JS挖矿脚本。
  5. 根据权利要求4所述的方法,其特征在于,所述触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本,包括:
    触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
    如果判断结果为是,则确定所述终端使用的浏览器支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第一JS挖矿脚本;
    如果判断结果为否,则确定所述终端使用的浏览器不支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第二JS挖矿脚本。
  6. 根据权利要求2所述的方法,其特征在于,所述将所述至少一个JS挖矿脚本的链接嵌入目标网页, 包括:
    生成所述第一JS挖矿脚本的链接和所述第二JS挖矿脚本的链接;
    根据历史记录中所述目标网页中被支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第二位置区域,所述第二位置区域是所述目标网页中各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
    根据历史记录中所述目标网页中被不支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第三位置区域,所述第三位置区域是所述目标网页中各位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
    将所述第一JS挖矿脚本的链接嵌入所述目标网页的所述第二位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的所述第三位置区域。
  7. 根据权利要求6所述的方法,其特征在于,所述当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本,包括:
    当检测到所述第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
    如果判断结果为是,则确定所述终端使用的浏览器支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本;
    如果判断结果为否,则在检测到所述第二JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本。
  8. 一种终端,其特征在于,包括:
    获取单元,用于获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本;
    嵌入单元,用于生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页;
    触发单元,用于当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
  9. 根据权利要求8所述的终端,其特征在于,所述获取单元401获取JS挖矿脚本库时,具体用于:
    建立所述JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本;
    其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
  10. 根据权利要求8所述的终端,其特征在于,所述嵌入单元402将所述至少一个JS挖矿脚本的链接嵌入目标网页时,具体用于:
    根据历史记录中所述目标网页中各位置区域的数据信息被爬取的概率确定第一位置区域,所述第一位置区域是所述目标网页中各位置区域的数据信息被爬取概率最大的位置区域;
    将所述至少一个JS挖矿脚本的链接嵌入所述目标网页的所述第一位置区域。
  11. 根据权利要求9所述的终端,其特征在于,所述触发单元403当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本时,具体用于:
    当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本;
    调用所述终端使用的浏览器加载并执行所述终端选取的所述第一JS挖矿脚本或第二JS挖矿脚本。
  12. 根据权利要求11所述的终端,其特征在于,所述触发单元403触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本时,具体用于:
    触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
    如果判断结果为是,则确定所述终端使用的浏览器支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第一JS挖矿脚本;
    如果判断结果为否,则确定所述终端使用的浏览器不支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第二JS挖矿脚本。
  13. 根据权利要求9所述的终端,其特征在于,所述嵌入单元402将所述至少一个JS挖矿脚本的链接嵌入目标网页时,具体用于:
    生成所述第一JS挖矿脚本的链接和所述第二JS挖矿脚本的链接;
    根据历史记录中所述目标网页中被支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第二位置区域,所述第二位置区域是所述目标网页中各位置区域的数据信息被支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
    根据历史记录中所述目标网页中被不支持所述WebAssembly语言的浏览器爬取各位置区域的数据信息的概率确定第三位置区域,所述第三位置区域是所述目标网页中各位置区域的数据信息被不支持所述WebAssembly语言的浏览器爬取概率最大的位置区域;
    将所述第一JS挖矿脚本的链接嵌入所述目标网页的所述第二位置区域,以及将所述第二JS挖矿脚本的链接嵌入所述目标网页的所述第三位置区域。
  14. 根据权利要求13所述的终端,其特征在于,所述触发单元403当检测到所述至少一个JS挖矿 脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本时,具体用于:
    当检测到所述第一JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
    如果判断结果为是,则确定所述终端使用的浏览器支持所述WebAssembly语言,并触发访问所述目标网页的终端使用的浏览器加载并执行所述第一JS挖矿脚本;
    如果判断结果为否,则在检测到所述第二JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端使用的浏览器加载并执行所述第二JS挖矿脚本。
  15. 一种终端,其特征在于,包括处理器、输入设备、输出设备和存储器,所述处理器、输入设备、输出设备和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令以执行如下步骤:
    获取JS挖矿脚本库,所述JS挖矿脚本库包括至少一个JS挖矿脚本;
    生成所述至少一个JS挖矿脚本的链接,将所述至少一个JS挖矿脚本的链接嵌入目标网页;
    当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本。
  16. 根据权利要求15所述的终端,其特征在于,所述处理器获取JS挖矿脚本库时,具体用于:
    建立所述JS挖矿脚本库,所述JS挖矿脚本库包括第一JS挖矿脚本和第二JS挖矿脚本;
    其中,所述第一JS挖矿脚本是WebAssembly语言的脚本,所述第二JS挖矿脚本是JS语言的脚本。
  17. 根据权利要求15所述的终端,其特征在于,所述处理器所述至少一个JS挖矿脚本的链接嵌入目标网页时,具体用于:
    根据历史记录中所述目标网页中各位置区域的数据信息被爬取的概率确定第一位置区域,所述第一位置区域是所述目标网页中各位置区域的数据信息被爬取概率最大的位置区域;
    将所述至少一个JS挖矿脚本的链接嵌入所述目标网页的所述第一位置区域。
  18. 根据权利要求16所述的终端,其特征在于,所述处理器当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端加载并执行所述至少一个JS挖矿脚本时,具体用于:
    当检测到所述至少一个JS挖矿脚本的链接的启动指令时,触发访问所述目标网页的终端根据所述终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本;
    调用所述终端使用的浏览器加载并执行所述终端选取的所述第一JS挖矿脚本或第二JS挖矿脚本。
  19. 根据权利要求18所述的终端,其特征在于,所述处理器触发访问所述目标网页的终端根据所述 终端使用的浏览器所支持的语言,选取所述第一JS挖矿脚本或第二JS挖矿脚本时,具体用于:
    触发访问所述目标网页的终端判断所述终端使用的浏览器版本号是否为预设版本号集合中的任意一种;
    如果判断结果为是,则确定所述终端使用的浏览器支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第一JS挖矿脚本;
    如果判断结果为否,则确定所述终端使用的浏览器不支持WebAssembly语言,从所述JS挖矿脚本库中选取所述第二JS挖矿脚本。
  20. 一种计算机可读存储介质,其特征在于,所述计算机存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
PCT/CN2018/108672 2018-06-27 2018-09-29 一种反爬虫方法、终端及计算机可读存储介质 Ceased WO2020000747A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810685659.3 2018-06-27
CN201810685659.3A CN108898009A (zh) 2018-06-27 2018-06-27 一种反爬虫方法、终端及计算机可读介质

Publications (1)

Publication Number Publication Date
WO2020000747A1 true WO2020000747A1 (zh) 2020-01-02

Family

ID=64346831

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/108672 Ceased WO2020000747A1 (zh) 2018-06-27 2018-09-29 一种反爬虫方法、终端及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN108898009A (zh)
WO (1) WO2020000747A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488546A (zh) * 2020-04-13 2020-08-04 北京小米移动软件有限公司 一种页面生成方法、装置及存储介质
CN112804269A (zh) * 2021-04-14 2021-05-14 中建电子商务有限责任公司 一种实现网站接口反爬虫的方法
CN114386059A (zh) * 2021-12-15 2022-04-22 北京五八信息技术有限公司 网页文本混淆反爬虫方法、装置、电子设备及存储介质
CN114444079A (zh) * 2021-12-31 2022-05-06 广东安创信息科技开发有限公司 基于bs架构的反爬虫方法、装置、设备及存储介质
CN115687728A (zh) * 2021-07-12 2023-02-03 中移(苏州)软件技术有限公司 一种页面访问方法、装置、电子设备及存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111585961B (zh) * 2020-04-03 2021-08-20 北京大学 一种网页挖矿攻击检测及保护方法和装置
CN111832024B (zh) * 2020-07-27 2021-09-24 东方财富信息股份有限公司 一种大数据安全防护方法及系统
CN112463526A (zh) * 2020-11-13 2021-03-09 苏州浪潮智能科技有限公司 一种服务器状态的获取方法及相关装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833212A (zh) * 2011-06-14 2012-12-19 阿里巴巴集团控股有限公司 网页访问者身份识别方法及系统
CN105743901A (zh) * 2016-03-07 2016-07-06 携程计算机技术(上海)有限公司 服务器、反爬虫系统和反爬虫验证方法
US20170346804A1 (en) * 2015-06-02 2017-11-30 ALTR Solutions, Inc. Credential-free user login to remotely executed applications
CN107908959A (zh) * 2017-11-10 2018-04-13 北京知道创宇信息技术有限公司 网站信息检测方法、装置、电子设备及存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102833212A (zh) * 2011-06-14 2012-12-19 阿里巴巴集团控股有限公司 网页访问者身份识别方法及系统
US20170346804A1 (en) * 2015-06-02 2017-11-30 ALTR Solutions, Inc. Credential-free user login to remotely executed applications
CN105743901A (zh) * 2016-03-07 2016-07-06 携程计算机技术(上海)有限公司 服务器、反爬虫系统和反爬虫验证方法
CN107908959A (zh) * 2017-11-10 2018-04-13 北京知道创宇信息技术有限公司 网站信息检测方法、装置、电子设备及存储介质

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488546A (zh) * 2020-04-13 2020-08-04 北京小米移动软件有限公司 一种页面生成方法、装置及存储介质
CN111488546B (zh) * 2020-04-13 2023-09-26 北京小米移动软件有限公司 一种页面生成方法、装置及存储介质
CN112804269A (zh) * 2021-04-14 2021-05-14 中建电子商务有限责任公司 一种实现网站接口反爬虫的方法
CN112804269B (zh) * 2021-04-14 2021-07-06 中建电子商务有限责任公司 一种实现网站接口反爬虫的方法
CN115687728A (zh) * 2021-07-12 2023-02-03 中移(苏州)软件技术有限公司 一种页面访问方法、装置、电子设备及存储介质
CN114386059A (zh) * 2021-12-15 2022-04-22 北京五八信息技术有限公司 网页文本混淆反爬虫方法、装置、电子设备及存储介质
CN114444079A (zh) * 2021-12-31 2022-05-06 广东安创信息科技开发有限公司 基于bs架构的反爬虫方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN108898009A (zh) 2018-11-27

Similar Documents

Publication Publication Date Title
WO2020000747A1 (zh) 一种反爬虫方法、终端及计算机可读存储介质
CN109325195B (zh) 浏览器的渲染方法和系统、计算机设备、计算机存储介质
US20150012924A1 (en) Method and Device for Loading a Plug-In
US20160065613A1 (en) System and method for detecting malicious code based on web
WO2021098242A1 (zh) 页面处理方法、装置、电子设备和计算机可读介质
CN108733559B (zh) 页面事件的触发方法、终端设备及介质
WO2016177341A1 (zh) 接口调用方法、装置及终端
CN110365724B (zh) 任务处理方法、装置及电子设备
CN114297700B (zh) 动静态结合的移动应用隐私协议提取方法及相关设备
CN111158777B (zh) 组件调用方法、装置及计算机可读存储介质
CN110298000A (zh) 页面参数的获取方法、终端设备及介质
CN114328073A (zh) 线程监控方法、装置、设备及存储介质
CN109325192B (zh) 一种广告防屏蔽的方法和装置
US9436669B1 (en) Systems and methods for interfacing with dynamic web forms
CN104899217B (zh) 一种自定义功能的实现方法及装置
TW201411382A (zh) 瀏覽器引擎運行方法、裝置、瀏覽器及終端
WO2020073493A1 (zh) Sql注入漏洞检测方法、装置、设备及可读存储介质
CN108268298B (zh) 桌面图标的生成方法、装置、存储介质及电子设备
US20150154314A1 (en) Method, apparatus and terminal for webpage content browsing
WO2021051583A1 (zh) 变量的传输和收集方法、装置及计算机可读存储介质
CN116451271A (zh) 一种应用软件的隐私政策自动提取方法
CN115987638A (zh) 一种网页漏洞检测方法、装置、设备及存储介质
CN113590996A (zh) 一种埋点数据生成方法、装置、设备及存储介质
US12143369B1 (en) Systems and methods for dynamically classifying browser fingerprinting into user tracking and cloaking
CN112269592A (zh) 一种全局功能的生效方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18925017

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 08.04.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18925017

Country of ref document: EP

Kind code of ref document: A1