A web page identification method, device, equipment and storage medium

By performing pixel value difference segmentation and target detection on web page screenshots, the web page type is automatically identified, which solves the problem that existing technology cannot identify undiscovered and newly added bad web pages, achieves effective identification and restriction of bad web pages, and improves the network Security.

CN112036412BActive Publication Date: 2024-08-27NSFOCUS INFORMATION TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010882588.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-28
Publication Date
2024-08-27
Estimated Expiration
2040-08-28

AI Technical Summary

Technical Problem

Existing blacklist methods cannot effectively identify and restrict undiscovered and newly added bad web pages, resulting in a large amount of undetected bad information that may exist in the network.

Method used

By obtaining web page screenshots, segmenting the image based on the difference in pixel values ​​of the web page screenshots, generating target detection images, and determining its type probability, the web page type can be automatically identified and the identification and restriction of undiscovered or newly added bad web pages can be achieved.

Benefits of technology

This method can reduce the complexity of web page identification, improve the security of network access, ensure timely identification and restriction of unknown and new bad web pages, and improve the security of the network environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112036412B
    Figure CN112036412B
Patent Text Reader

Abstract

The present application provides a web page recognition method, device, equipment and storage medium, which relates to the field of computer technology and is used to realize automatic detection of web page types and reduce the complexity of web page recognition. The method includes: obtaining a web page screenshot of a web page to be recognized according to the uniform resource locator URL of the web page to be recognized; determining an image segmentation line of the web page screenshot according to the difference between the pixel values ​​of each row or column of the web page screenshot, and performing image segmentation on the web page screenshot according to the image segmentation line to obtain at least one target detection image; determining the probability that each target detection image in at least one target detection image belongs to the target image type, and determining the probability that the web page to be recognized belongs to the target web page type according to the probability of each target image; when the probability that the web page to be recognized belongs to the target web page type is greater than a set probability threshold, determining the type of the web page to be recognized as the target web page type.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology and provides a web page recognition method, device, equipment and storage medium. Background Art

[0002] When users browse the web, there may be some web pages containing bad information on the Internet, which are not conducive to the physical and mental health of specific users. Therefore, these illegal web pages need to be restricted.

[0003] At present, the most commonly used method for these bad web pages is the blacklist method. The blacklist method manually adds web page URLs or domain names containing known bad information to the blacklist address library, and further restricts the web page URLs and related information visited by users by comparing the addresses and keywords of the web pages visited by users with the blacklist.

[0004] However, the above blacklist method cannot limit undiscovered and newly added bad web pages. Summary of the invention

[0005] The embodiments of the present application provide a web page recognition method, apparatus, device and storage medium for realizing automatic detection of web page types and reducing the complexity of web page recognition.

[0006] In one aspect, a web page recognition method is provided, the method comprising:

[0007] Obtaining a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified;

[0008] Determine an image segmentation line of the webpage screenshot according to the difference between pixel values ​​of each row or column of the webpage screenshot, and perform image segmentation on the webpage screenshot according to the image segmentation line to obtain at least one target detection picture;

[0009] Determine the probability that each target detection image in at least one target detection image belongs to the target image type, and determine the probability that the web page to be identified belongs to the target web page type based on the probability of each target image; when the probability that the web page to be identified belongs to the target web page type is greater than a set probability threshold, determine that the type of the web page to be identified is the target web page type.

[0010] Optionally, determining the probability that the web page to be identified belongs to the target web page type according to the probability of each target image includes:

[0011] The probability that the web page to be identified belongs to the target web page type is determined according to the probability of each target image and the weight value set for each target image.

[0012] In one aspect, a web page recognition device is provided, the device comprising:

[0013] An acquisition unit, used to acquire a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified;

[0014] A determination unit, configured to determine an image segmentation line of the webpage screenshot according to a difference between pixel values ​​of each row or column of the webpage screenshot;

[0015] An image segmentation unit, used to segment the webpage screenshot according to the image segmentation line to obtain at least one target detection picture;

[0016] The determination unit is further used to determine the probability that each target detection image in at least one target detection image belongs to the target image type, and determine the probability that the web page to be identified belongs to the target web page type according to the probability of each target image; when the probability that the web page to be identified belongs to the target web page type is greater than a set probability threshold, determine that the type of the web page to be identified is the target web page type.

[0017] Optionally, the acquiring unit is used to:

[0018] Sending a URL access request to a web page server corresponding to the URL according to the URL;

[0019] Receiving a hypertext markup language HTML document corresponding to the URL returned by the web page server;

[0020] The HTML document is parsed, and rendering is performed according to the content obtained by parsing the HTML document to obtain the webpage screenshot.

[0021] Optional,

[0022] The determining unit is used to determine an image segmentation line of the webpage screenshot in the first direction according to the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot, wherein the first direction is a row direction or a column direction;

[0023] The image segmentation unit is used to perform image segmentation on the webpage screenshot based on the image segmentation line in the first direction to obtain a plurality of segmented images;

[0024] The determining unit is used to select a target segmented picture from the segmented pictures, and determine an image segmentation line of the target segmented picture in a second direction, wherein when the first direction is a row direction, the second direction is a column direction, or when the first direction is a column direction, the second direction is a row direction;

[0025] The image segmentation unit is used to perform image segmentation on the target segmented picture based on the image segmentation line in the second direction to obtain a plurality of segmented pictures;

[0026] The determining unit is used to determine the multiple segmented pictures obtained by segmenting the image based on the image segmentation line in the first direction and the multiple segmented pictures obtained by segmenting the image based on the image segmentation line in the second direction as the at least one target detection picture.

[0027] Optionally, the determining unit is used to:

[0028] Determine the difference between each pixel value in each group of pixel values ​​in a first direction in the webpage screenshot; wherein the first direction is a row direction and each group of pixel values ​​is a row of pixel values, or wherein the first direction is a column direction and each group of pixel values ​​is a column of pixel values;

[0029] When the difference between each group of pixel values ​​is less than a set difference threshold, the pixel points corresponding to each group of pixel values ​​are determined as image segmentation lines of the webpage screenshot.

[0030] Optionally, the determining unit is used to:

[0031] Determine the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot;

[0032] A representation sequence of the webpage screenshot in the first direction is obtained according to the difference of each group of pixel values; wherein a group of pixel values ​​corresponds to a position in the representation sequence, and adjacent groups are adjacent in position in the representation sequence, and when the difference of each group of pixel values ​​is less than a set difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a first value, and when the difference of each group of pixel values ​​is greater than or equal to the difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a second value, and the first value is different from the second value;

[0033] An image segmentation line of the webpage screenshot in the first direction is determined according to the representation sequence.

[0034] Optionally, the determining unit is used to:

[0035] For each group of pixel values, taking one pixel value in each group of pixel values ​​as a reference pixel value, obtaining the difference between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value;

[0036] Based on the differences between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, the difference of each group of pixel values ​​is obtained.

[0037] Optionally, the determining unit is used to:

[0038] Obtain a second number of intervals in the representation sequence where the sequence values ​​are consecutively the second value;

[0039] Determining whether the second quantity is less than or equal to a set quantity threshold;

[0040] If it is determined that the second number is greater than the set number threshold, the following loop process is performed until the second number is less than or equal to the set number value, and each loop process includes the following steps:

[0041] For each interval in which the sequence value is continuously the second value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the first value to obtain a first updated sequence;

[0042] For each interval in the updated representation sequence in which the sequence value is continuously the first value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the second value to obtain a second updated sequence;

[0043] Determining whether a second quantity in the second update sequence is less than or equal to a set quantity threshold;

[0044] If it is determined that the second number in the second update sequence is greater than the set number threshold, then the next cycle is entered; or,

[0045] If it is determined that the second number in the second update sequence is less than or equal to the set number threshold, the loop ends.

[0046] Optionally, the length threshold is set according to the number of cycles.

[0047] Optionally, the determining unit is used to:

[0048] The probability that the web page to be identified belongs to the target web page type is determined according to the probability of each target image and the weight value set for each target image.

[0049] On the one hand, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above methods when executing the computer program.

[0050] In one aspect, a computer storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the steps of any of the above methods are implemented.

[0051] In one aspect, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any of the above methods.

[0052] In the embodiment of the present application, a webpage screenshot is obtained according to the URL, an image segmentation line of the webpage screenshot is determined according to the difference between the pixel values ​​of each row or column of the webpage screenshot, and the webpage screenshot is segmented according to the image segmentation line to obtain at least one target detection image, thereby determining the probability that each target detection image belongs to the target image type, and then determining the probability that the webpage to be identified belongs to the target webpage type, so as to determine whether the type of the webpage to be identified is the target webpage type. Therefore, the embodiment of the present application can automatically generate a webpage screenshot, divide the webpage screenshot into multiple images for detection, and finally determine the type of the webpage by combining the detection results of multiple images, so that for undiscovered or newly added bad webpages, identification and detection can still be performed, thereby restricting the access to bad webpages, improving the security of network access, and reducing the complexity of webpage identification. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0054] Figure 1 A schematic diagram of an application scenario of the web page recognition device provided in an embodiment of the present application;

[0055] Figure 2 A schematic diagram of a flow chart of a web page identification method provided in an embodiment of the present application;

[0056] Figure 3 A schematic diagram of a webpage screenshot provided in an embodiment of the present application;

[0057] Figure 4 A schematic diagram of a process for obtaining a representation sequence provided in an embodiment of the present application;

[0058] Figure 5 A schematic diagram of a process of representing sequence transformation provided in an embodiment of the present application;

[0059] Figure 6 A schematic diagram of the probability of obtaining a target image by taking a screenshot of a web page provided in an embodiment of the present application;

[0060] Figure 7 A schematic diagram of a web page recognition device provided in an embodiment of the present application;

[0061] Figure 8 A schematic diagram of a web page recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other arbitrarily. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.

[0063] At present, the commonly used blacklist method cannot identify a large number of undiscovered and newly added bad web pages. At present, it is also possible to use the method of obtaining all the pictures in the web page and identifying and detecting each picture to determine whether the web page is a bad web page, but this method requires detecting a large number of picture resources in the web page, which consumes a lot of resources.

[0064] Based on this, an embodiment of the present application provides a web page recognition method, in which a web page screenshot is obtained according to a URL, an image segmentation line of the web page screenshot is determined according to the difference between the pixel values ​​of each row or column of the web page screenshot, and the web page screenshot is segmented according to the image segmentation line to obtain at least one target detection image, thereby determining the probability that each target detection image belongs to the target image type, and then determining the probability that the web page to be identified belongs to the target web page type, so as to determine whether the type of the web page to be identified is the target web page type. Therefore, the embodiment of the present application automatically generates a web page screenshot, divides the web page screenshot into multiple images for detection, and finally determines the type of the web page by combining the detection results of multiple images, so that for undiscovered or newly added bad web pages, identification and detection can still be performed, thereby restricting access to bad web pages.

[0065] After introducing the design ideas of the embodiments of the present application, the following briefly introduces the application scenarios to which the technical solutions of the embodiments of the present application can be applied. It should be noted that the application scenarios introduced below are only used to illustrate the embodiments of the present application and are not limited. In the specific implementation process, the technical solutions provided by the embodiments of the present application can be flexibly applied according to actual needs.

[0066] like Figure 1 FIG. 1 is a schematic diagram of an application scenario of a web page recognition device provided in an embodiment of the present application. The application scenario of web page recognition may include a web page recognition device 10 .

[0067] The web page recognition device 10 is a computer device with certain processing capabilities, such as a personal computer (PC), a laptop or a server. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, but is not limited to these.

[0068] The web page recognition device 10 includes one or more processors 101, a memory 102, and an I / O interface 103 for interacting with other devices. In addition, the web page recognition device 10 may also be configured with a database 104, which may be used to store data such as web page recognition data, acquired web page addresses, and recognition results of each web page involved in the solution provided in the embodiment of the present application. Among them, the memory 102 of the web page recognition device 10 may store program instructions of the web page recognition method provided in the embodiment of the present application, and these program instructions, when executed by the processor 101, can be used to implement the steps of the web page recognition method provided in the embodiment of the present application to determine whether a web page belongs to the target web page type.

[0069] In actual use, when a user browses the web, there may be some web pages containing bad information on the network, which is not conducive to the physical and mental health of specific users. Therefore, these illegal web pages need to be restricted, so these illegal web pages can be restricted through the web page recognition device 10.

[0070] In the embodiment of the present application, the web page to be identified may be an input web page, or a web page in a pre-prepared web page list, wherein the web page list may be a web page corresponding to a web page address captured from the network; or a web page obtained from network traffic data, for example, a web page corresponding to a web page address in a web page access request packet captured from network traffic data. The web page identification device 10 determines whether a web page belongs to a target web page type web page based on the web page identification method provided in the embodiment of the present application, and adds the web pages belonging to the target web page type to a restriction blacklist to restrict access to these web pages.

[0071] Of course, the method provided in the embodiment of the present application is not limited to Figure 1 The application scenarios shown can also be used in other possible application scenarios, and the embodiments of the present application are not limited thereto. Figure 1 The functions that can be realized by each device in the application scenario shown will be described in the subsequent method embodiments, and will not be described in detail here. Below, the method of the embodiment of the present application will be introduced in conjunction with the accompanying drawings.

[0072] like Figure 2 FIG. 1 is a flow chart of a web page recognition method according to an embodiment of the present application. The method can be performed by Figure 1 The method is performed by the web page recognition device 10, and the process of the method is described as follows.

[0073] Step 201: Obtain a screenshot of the web page to be identified according to the URL of the web page to be identified.

[0074] In an embodiment of the present application, the web page identification device can obtain the URL of the web page to be identified from the web page input by the user, or it can also obtain the URL of the web page from a web page in a pre-prepared web page list, wherein the web page list can be a web page corresponding to a web page address captured from the network, or it can also obtain the URL of the web page from a web page obtained from network traffic data, for example, a web page corresponding to a web page address in a web page access request packet captured from network traffic data.

[0075] The web page recognition device can obtain a web page screenshot of the web page to be recognized by simulating the process of a browser accessing a URL through a URL. Specifically, a URL access request can be sent to a web page server corresponding to the URL according to the URL, a Hyper Text Markup Language (HTML) document returned by the web page server is received, the HTML document is parsed, and then the web page structure and the content to be displayed at each position in the web page are obtained based on the HTML document, and the web page structure and the content to be displayed are rendered according to the web page structure and the content to be displayed, thereby generating a web page screenshot of the web page to be recognized.

[0076] In actual use, the web page recognition device can not only obtain the URL through the web page input by the user, but also crawl the URL using the standard urllib library included in the python library. The web page recognition device accesses the web page to be recognized based on the URL based on the web page access module included in the browser engine to obtain the HTML document of the web page to be recognized, and loads the HTML document into the memory and executes various scripts included in the HTML document. Since there is no need to provide a visual interface to the user, the various scripts included in the HTML document can be executed in the background of the program without displaying the graphical interface of the web page. Specifically, the browser engine can be, for example, Webkit, and the web page access module can be, for example, phantomjs included in Webkit.

[0077] After the HTML document is executed in the background, you can call the screenshot command of the screenshot tool to obtain a screenshot of the web page. For example, call the screenshot command of Web's selenium to obtain a screenshot of the web page.

[0078] In the embodiment of the present application, in addition to taking screenshots, the web page content can also be generated into a portable document format (PDF) document, and text recognition can be performed on the PDF document later.

[0079] Step 202: determining an image segmentation line of the webpage screenshot according to the difference between pixel values ​​of each row or column of the webpage screenshot, and performing image segmentation on the webpage screenshot according to the image segmentation line to obtain at least one target detection picture.

[0080] In an embodiment of the present application, before performing image segmentation on the web page screenshot of the web page to be identified, the web page recognition device can perform image scaling processing on the web page screenshot to keep the web page screenshot at a fixed size so that the web page recognition device can subsequently perform image processing on the web page screenshot.

[0081] Since actual bad web pages may include a large number of bad pictures or videos, and there are often blank areas between pictures and videos, these blank areas can be used as dividing lines to divide web page screenshots when segmenting web pages. Figure 3 As shown, it is a schematic diagram of a web page screenshot provided in an embodiment of the present application, wherein the web page screenshot contains information such as pictures and texts, and there are blank areas between different pictures, or between pictures and text blocks, so the web page screenshot can be segmented by these blank areas.

[0082] Specifically, in the webpage screenshot, the pixel values ​​of the blank area are basically the same or have little difference, so the image segmentation line of the webpage screenshot can be determined according to the difference between the pixel values ​​of each row or column of the webpage screenshot. Among them, a 2D webpage screenshot has a pixel distribution direction including a row direction and a column direction, and the segmentation line can be determined in both the row direction and the column direction, so segmentation can be performed in one direction first, and then segmentation in the other direction.

[0083] Specifically, the image segmentation line of the web page screenshot in the first direction can be determined according to the difference between the pixel values ​​in each group of pixel values ​​in the first direction in the web page screenshot, and then the web page screenshot can be segmented based on the image segmentation line in the first direction to obtain multiple segmented pictures, and then the target segmentation picture is selected from the segmented pictures, and the image segmentation line of the target segmentation picture in the second direction is determined, and then the target segmentation picture is segmented based on the image segmentation line in the second direction to obtain multiple segmented pictures. The final picture is used as the at least one target detection picture mentioned above, that is, the multiple segmentation pictures obtained by segmentation based on the image segmentation line in the first direction and the multiple segmentation pictures obtained by segmentation based on the image segmentation line in the second direction are determined as at least one target detection picture.

[0084] In actual application, the target segmentation picture may be selected randomly or by designated selection from the segmentation pictures. For example, after three segmentation pictures are obtained by segmentation, the middle segmentation picture may be used as the target segmentation picture.

[0085] The first direction is a row direction or a column direction, and the second direction is a direction different from the first direction. When the first direction is a row direction, the second direction is a column direction, or when the first direction is a column direction, the second direction is a row direction.

[0086] Since the segmentation process in the first direction and the second direction are similar, the image segmentation process is introduced below by taking the first direction as an example.

[0087] In the actual implementation process, the image segmentation line in the first direction can be determined by determining the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot. Specifically, when determining the difference, for each group of pixel values ​​in the first direction, one of the pixel values ​​in the group of pixel values ​​can be used as a reference pixel value to obtain the difference between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, and then based on the difference between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, the difference of each group of pixel values ​​is obtained.

[0088] When the first direction is a row direction, each group of pixel values ​​may be a row of pixel values; or, when the first direction is a column direction, each group of pixel values ​​may be a column of pixel values.

[0089] Specifically, the reference pixel value in a group of pixel values ​​may be, for example, the pixel value of the first row or the first column. Of course, it may also be other possible pixel values, and the embodiment of the present application does not impose any limitation on this.

[0090] After obtaining the differences between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, the sum of the differences can be used as the difference of the group of pixel values, or the mean of the differences can be calculated as the difference of the group of pixel values.

[0091] In the embodiment of the present application, the method of determining the image segmentation line based on the difference degree may include the following two methods.

[0092] First method

[0093] In an embodiment of the present application, after obtaining the difference of each group of pixel values, it can be determined whether the difference of each group of pixel values ​​is less than a set difference threshold. When it is determined that the difference of the group of pixel values ​​is less than the set difference threshold, the pixel points corresponding to the group of pixel values ​​are determined to be the image dividing line of the web page screenshot. Otherwise, the pixel points corresponding to the group of pixel values ​​are not the image dividing line of the web page screenshot.

[0094] Second method

[0095] In the embodiment of the present application, a representation sequence of the webpage screenshot in the first direction is obtained according to the difference of each group of pixel values. Wherein, a group of pixel values ​​corresponds to a position in the representation sequence, and adjacent groups are adjacent in the representation sequence. When the difference of a group of pixel values ​​is less than a set difference threshold, the sequence value of the corresponding position of the group of pixel values ​​is a first value B0, and when the difference of the group of pixel values ​​is greater than or equal to the difference threshold, the sequence value of the corresponding position of the group of pixel values ​​is a second value B1. The first value B0 and the second value B1 are different values, for example, the first value B0 is 0, the second value B1 is 1, or the first value B0 is 1, and the second value B1 is 0.

[0096] Specifically, taking the first direction as the row direction as an example, the webpage screenshot can be binarized according to the following rules to obtain a representation sequence. The binarization rules are as follows:

[0097]

[0098] Among them, N is the difference threshold, P (i,w) is the pixel value of the i-th row and w-th column, P i is the reference pixel value of the i-th row, All(|P (i,w) -P i |) represents the difference of the i-th row. When the difference of the pixel values ​​of the i-th row is less than the set difference threshold N, the position of the i-th row in the representation sequence is B0. When the difference of the pixel values ​​of the i-th row is other cases, that is, greater than or equal to the set difference threshold N, the position of the i-th row in the representation sequence is B1.

[0099] like Figure 4 As shown, it is a schematic diagram of the process of obtaining the representation sequence. Figure 4 Taking behavior as an example, Figure 4 The middle left picture is the pixel array of the web page screenshot, and the right picture is the representation sequence corresponding to the web page screenshot. Through the above-mentioned binarization process, the pixel array of a web page screenshot can be converted into a representation sequence, wherein each small grid of the pixel image represents a pixel point, and each pixel point contains a corresponding pixel value. Each small grid of the representation sequence represents the binary value of a row of pixel values ​​corresponding to the pixel image of the web page screenshot.

[0100] In the embodiment of the present application, after obtaining the representation sequence, the image segmentation line of the webpage screenshot in the first direction can be determined according to the representation sequence. Figure 4 As shown, the pixel group corresponding to the position B0 in the representation sequence can be determined as the image segmentation line.

[0101] In the embodiment of the present application, it is considered that there may be noise in the webpage screenshot, which may cause the image segmentation line to be determined inaccurately. For example, the pixel value of a row of the webpage screenshot may change one or more pixel values ​​of the row due to noise, resulting in a very large difference in pixel values ​​of the row that should have been very small, so that the row cannot be an image segmentation line.

[0102] Therefore, in the embodiment of the present application, after obtaining the representation sequence, the representation sequence can be denoised to improve the accuracy of determining the image segmentation line, thereby improving the accuracy of subsequent image recognition.

[0103] Specifically, the web page recognition device can obtain the representation sequence S v The first number of intervals R0 whose sequence values ​​are continuously the first value B0 and the second number of intervals R1 whose sequence values ​​are continuously the second value B1, the number of target segmented images finally obtained may affect the accuracy of subsequent determination that the web page to be identified belongs to the target web page type. Therefore, a number threshold C of the target segmented images finally obtained can be set. The interval R1 whose sequence value is continuously the second value B1 corresponds to the target segmented image obtained by segmentation. Therefore, the web page recognition device can determine the size relationship between the second number C1 and the number threshold C.

[0104] When the second number C1 is greater than the set number threshold C, the following loop process is performed until the second number C1 is less than or equal to the set number threshold C, so as to limit the number of target segmentation pictures to reduce the error segmentation caused by noise. Each loop process may include the following steps:

[0105] First, for each interval in which the sequence value is continuously the second value B1, when the length of the interval is less than or equal to the length threshold T, the sequence value of the interval is set to the first value B0, and a first update sequence is obtained. In which, the positions in the sequence that are continuously the second value B1 are an interval, or the positions that are continuously the first value B0 are an interval, and the length of the interval is the number of positions included in the interval in the sequence, such as Figure 4 As shown, the top position of "1" is an interval, the second adjacent position of "0" can also be an interval, and the 9 consecutive positions of "1" at the bottom can also be an interval.

[0106] Secondly, for each interval in the updated representation sequence whose sequence value is continuously the first value B0, if the length of the interval is less than or equal to the length threshold T, the sequence value of the interval is set to the second value B1 to obtain a second updated sequence.

[0107] Finally, it is determined whether the second number in the second update sequence is less than or equal to the set number threshold C. When the second number in the second update sequence is greater than the set number threshold C, it indicates that the number of target segmented pictures is still large, so the next cycle is entered; otherwise, when the second number in the second update sequence is less than or equal to the set number threshold C, the cycle ends.

[0108] In an embodiment of the present application, the quantity threshold C can be set to 3, for example, and of course can also be set to other possible values. The embodiment of the present application does not limit this. The length threshold T can be set according to the number of cycles. For example, the initial length threshold T can be zero. As the number of cycles increases, the length threshold T increases successively. For example, the length threshold T in each cycle can be increased by one based on the number of cycles.

[0109] like Figure 5 As shown, a schematic diagram of a process of representing sequence transformation provided by an embodiment of the present application can be used to obtain a new representation sequence by updating the original sequence. When the original sequence is updated for the first time, for each interval whose sequence value is continuously the second value B1, the sequence value of the interval whose length is less than or equal to the length threshold T is set to the first value B0, for example Figure 5 In the first and third cells of the original sequence, 1 is replaced with 0 to obtain the first updated sequence. In the second update, for each interval in the updated representation sequence whose sequence value is continuously the first value B0, if the length of the interval is less than or equal to the length threshold T, the sequence value of the interval is set to the second value B1, for example Figure 5 The 0 in the seventh cell of the first update sequence is replaced by 1 to obtain the second update sequence.

[0110] In the embodiment of the present application, the web page recognition device can use the pixel group corresponding to the first value B0 position in the finally obtained representation sequence as the segmentation pixel group, and the pixel point corresponding to the pixel group is the image segmentation line of the web page screenshot in the first direction, and perform image segmentation on the web page screenshot according to the image segmentation line in the first direction to obtain multiple segmentation pictures. For example, when the first direction is the row direction, the row corresponding to the first value B0 position in the finally obtained representation sequence can be used as the segmentation row to segment the web page screenshot.

[0111] In an embodiment of the present application, after selecting a target segmentation picture from the multiple segmentation pictures obtained, in order to facilitate image processing, the target segmentation picture can be swapped in rows and columns, and then, the same process as determining the image segmentation line in the first direction as mentioned above is used to obtain the image segmentation line in the second direction, and the target segmentation picture is segmented based on the image segmentation line in the second direction to obtain multiple segmentation pictures, thereby finally obtaining the above-mentioned at least one target detection picture.

[0112] Step 203: Determine the probability that each target detection picture in at least one target detection picture belongs to the target picture type, and determine the probability that the web page to be identified belongs to the target web page type according to the probability of each target picture.

[0113] In the present application embodiment, Figure 6 As shown, it is a schematic diagram of the probability of obtaining a target image from a webpage screenshot provided in an embodiment of the present application, wherein, after image segmentation, at least one target detection image can be obtained, and each target detection image can be detected using an image detection model to obtain the probability value of each target image in m image types, and then the image type to which the target detection image belongs can be obtained, for example, the image type with the highest probability value is the image type to which the target detection image belongs. In addition, the probability that each target detection image belongs to the target image type can also be obtained therefrom. For example, the image type may include normal, pornographic, or illegal types, and the target image type may be, for example, a pornographic image or an illegal image, and the probability that the target detection image belongs to a pornographic image or an illegal image can be detected by a pre-trained image detection model.

[0114] Furthermore, the probability that the web page to be identified belongs to the target web page type can be determined based on the probability of each target detection image and the weight value preset for each target image.

[0115] Specifically, the probability value of the target detection image and the corresponding weight value can be weighted and summed to obtain the probability T that the web page to be identified belongs to the target web page type. site Corresponding to the target image type, for example, when the target image type may be a pornographic image or an illegal image, the target web page type may be a pornographic web page or an illegal web page.

[0116] Exemplarily, when the number of obtained at least one target image is 5, the probabilities of obtaining 5 different types of the 5 target images after detection by the image detection method are 0.995, 0.001, 0.002, 0.001, and 0.002, respectively. The weight values ​​corresponding to the 5 target images are 0.9, 0.2, 0.4, 0.1, and 0.1, respectively. Then, the probability T of the web page type to which the web page to be identified belongs can be calculated according to the weighted summation formula. site =0.995×0.9+0.001×0.2+0.002×0.4+0.001×0.1+0.002×0.1=0.8968, that is, the probability that the web page to be identified belongs to the target web page type is 0.8968.

[0117] Step 204: When the probability that the webpage to be identified belongs to the target webpage type is greater than a set probability threshold, the type of the webpage to be identified is determined to be the target webpage type.

[0118] In the embodiment of the present application, a trust threshold T of the type of the web page to be identified as the target web page type is preset. confidence , when the calculated probability T of the type of the web page to be identified is the type of the target web page site The type of the web page to be identified is greater than or equal to the trust threshold T of the target web page type. confidence , it can be determined that the type of the web page to be identified is the target web page type.

[0119] In actual use, the trust threshold T can be set based on experience confidence , for example, you can set a trust threshold T confidence It can be set to 0.8, then when the calculated probability T of the type of the web page to be identified is the type of the target web page site When the probability T is greater than or equal to 0.8, the webpage recognition device determines that the type of the webpage to be recognized is the target webpage type. site =0.8968, 0.8968≥0.8, so it can be determined that the type of the web page to be identified is the target web page type.

[0120] In summary, the embodiments of the present application visualize the website content by simulating the human visual judgment process, and then conveniently divide it into one or more image areas, for example, up to 5 image areas for detection. Compared with complex text recognition in images, or recognition of hundreds or thousands of static pornographic images, or the need to download video resources and sample them by frame before identifying pornographic images, the technical solution of the embodiments of the present application is simpler, more resource-saving, and has a wider range of applications.

[0121] Based on the same inventive concept, the present application embodiment provides a web page recognition device, such as Figure 7 As shown, the device is applied to a web page recognition method, and the device includes:

[0122] The acquisition unit 701 is used to acquire a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified;

[0123] A determination unit 702, configured to determine an image segmentation line of the webpage screenshot according to a difference between pixel values ​​of each row or column of the webpage screenshot;

[0124] An image segmentation unit 703 is used to segment the webpage screenshot according to the image segmentation line to obtain at least one target detection picture;

[0125] The determination unit 702 is further used to determine the probability that each target detection image in at least one target detection image belongs to the target image type, and determine the probability that the web page to be identified belongs to the target web page type according to the probability of each target image; when the probability that the web page to be identified belongs to the target web page type is greater than a set probability threshold, determine that the type of the web page to be identified is the target web page type.

[0126] Optionally, the acquiring unit 701 is configured to:

[0127] Sending a URL access request to the web page server corresponding to the URL according to the URL;

[0128] Receiving a hypertext markup language HTML document corresponding to the URL returned by the web page server;

[0129] Parse the HTML document, render according to the content obtained by parsing the HTML document, and obtain a screenshot of the web page.

[0130] Optional,

[0131] A determining unit 702 is configured to determine an image segmentation line of the webpage screenshot in the first direction according to a difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot, wherein the first direction is a row direction or a column direction;

[0132] An image segmentation unit 703 is used to segment the webpage screenshot based on the image segmentation line in the first direction to obtain a plurality of segmented images;

[0133] A determining unit 702 is used to select a target segmented picture from the segmented pictures, and determine an image segmentation line of the target segmented picture in a second direction, wherein when the first direction is a row direction, the second direction is a column direction, or when the first direction is a column direction, the second direction is a row direction;

[0134] An image segmentation unit 703 is used to perform image segmentation on the target segmentation picture based on the image segmentation line in the second direction to obtain a plurality of segmentation pictures;

[0135] The determining unit 702 is configured to determine a plurality of segmented pictures obtained by segmenting the image based on the image segmentation line in the first direction and a plurality of segmented pictures obtained by segmenting the image based on the image segmentation line in the second direction as at least one target detection picture.

[0136] Optionally, the determining unit 702 is configured to:

[0137] Determine the difference between each pixel value in each group of pixel values ​​in a first direction in the webpage screenshot; wherein the first direction is a row direction and each group of pixel values ​​is a row of pixel values, or the first direction is a column direction and each group of pixel values ​​is a column of pixel values;

[0138] When the difference between each group of pixel values ​​is less than a set difference threshold, the pixel points corresponding to each group of pixel values ​​are determined as image segmentation lines of the webpage screenshot.

[0139] Optionally, the determining unit 702 is configured to:

[0140] Determine the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot;

[0141] Obtaining a representation sequence of the webpage screenshot in the first direction according to the difference of each group of pixel values; wherein a group of pixel values ​​corresponds to a position in the representation sequence, adjacent groups are adjacent in position in the representation sequence, and when the difference of each group of pixel values ​​is less than a set difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a first value, and when the difference of each group of pixel values ​​is greater than or equal to the difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a second value, and the first value is different from the second value;

[0142] An image segmentation line of the webpage screenshot in a first direction is determined according to the representation sequence.

[0143] Optionally, the determining unit 702 is configured to:

[0144] For each group of pixel values, taking one pixel value in each group of pixel values ​​as a reference pixel value, obtaining the difference between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value;

[0145] Based on the differences between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, the difference of each group of pixel values ​​is obtained.

[0146] Optionally, the determining unit 702 is configured to:

[0147] Get a second number representing intervals in the sequence where the sequence value is consecutively a second value;

[0148] Determining whether the second quantity is less than or equal to a set quantity threshold;

[0149] If it is determined that the second quantity is greater than the set quantity threshold, the following loop process is performed until the second quantity is less than or equal to the set quantity value, and each loop process includes the following steps:

[0150] For each interval in which the sequence value is continuously the second value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the first value to obtain a first updated sequence;

[0151] For each interval in the updated representation sequence where the sequence value is continuously the first value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the second value to obtain a second updated sequence;

[0152] Determining whether the second quantity in the second update sequence is less than or equal to a set quantity threshold;

[0153] If it is determined that the second number in the second update sequence is greater than the set number threshold, then the next cycle is entered; or,

[0154] If it is determined that the second number in the second update sequence is less than or equal to the set number threshold, the loop ends.

[0155] Optionally, a length threshold is set based on the number of loops.

[0156] Optionally, the determining unit 702 is configured to:

[0157] The probability that the web page to be identified belongs to the target web page type is determined according to the probability of each target image and the weight value set for each target image.

[0158] The device can be used to perform Figure 2 to Figure 6 Therefore, for the functions that can be realized by each functional module of the device, please refer to Figure 2 to Figure 6 The description of the illustrated embodiment is not repeated in detail.

[0159] See also Figure 8 Based on the same technical concept, the embodiment of the present application also provides a web page recognition device 80, which may include a memory 801 and a processor 802.

[0160] The memory 801 is used to store computer programs executed by the processor 802. The memory 801 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the computer device, etc. The processor 802 may be a central processing unit (CPU), or a digital processing unit, etc. The specific connection medium between the memory 801 and the processor 802 is not limited in the embodiments of the present application. The embodiments of the present application are Figure 8 In the embodiment, the memory 801 and the processor 802 are connected via a bus 803. The bus 803 is connected to the processor 802 via a bus 803. Figure 8 The connection between other components is shown by bold lines, and is not intended to be limiting. The bus 803 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0161] The memory 801 may be a volatile memory, such as a random-access memory (RAM); the memory 801 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 801 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 801 may be a combination of the above memories.

[0162] The processor 802 is used to execute the following when calling the computer program stored in the memory 801: Figure 2 to Figure 6 The method executed by the device in the illustrated embodiment.

[0163] In some possible implementations, various aspects of the method provided in the present application may also be implemented in the form of a program product, which includes a program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the method according to various exemplary embodiments of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 2 to Figure 6 The method executed by the device in the illustrated embodiment.

[0164] It can be understood by those skilled in the art that all or part of the steps of the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiment are executed; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks. Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in various embodiments of the present invention. And the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.

[0165] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0166] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A web page recognition method, It is characterized in that The method comprises: Obtaining a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified; Determining an image segmentation line of the webpage screenshot according to the difference between pixel values ​​of each row or column of the webpage screenshot, and performing image segmentation on the webpage screenshot according to the image segmentation line to obtain at least one target detection picture; Determine the probability that each target detection picture in the at least one target detection picture belongs to the target picture type, and determine the probability that the web page to be identified belongs to the target web page type according to the probability of each target picture; When the probability that the webpage to be identified belongs to the target webpage type is greater than a set probability threshold, determining the type of the webpage to be identified is the target webpage type; Among them, determining the image segmentation line of the web page screenshot according to the difference between the pixel values ​​of each row or column of the web page screenshot includes: determining the difference between each pixel value in each group of pixel values ​​in a first direction in the web page screenshot; wherein, the first direction is the row direction, and each group of pixel values ​​is a row of pixel values, or, the first direction is the column direction, and each group of pixel values ​​is a column of pixel values; when the difference between each group of pixel values ​​is less than a set difference threshold, determining the pixel point corresponding to each group of pixel values ​​as the image segmentation line of the web page screenshot.

2. The method according to claim 1, It is characterized in that The step of obtaining a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified includes: Sending a URL access request to a web page server corresponding to the URL according to the URL; Receiving a hypertext markup language HTML document corresponding to the URL returned by the web page server; The HTML document is parsed, and rendering is performed according to the content obtained by parsing the HTML document to obtain the webpage screenshot.

3. The method according to claim 1, It is characterized in that Determining an image segmentation line of the webpage screenshot according to the difference between pixel values ​​of each row or column of the webpage screenshot, and performing image segmentation on the webpage screenshot according to the image segmentation line to obtain at least one target detection picture, including: Determining an image segmentation line of the webpage screenshot in the first direction according to the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot, wherein the first direction is a row direction or a column direction; Performing image segmentation on the webpage screenshot based on the image segmentation line in the first direction to obtain a plurality of segmented images; Selecting a target segmented picture from the segmented pictures, and determining an image segmentation line of the target segmented picture in a second direction, wherein when the first direction is a row direction, the second direction is a column direction, or when the first direction is a column direction, the second direction is a row direction; Performing image segmentation on the target segmented picture based on the image segmentation line in the second direction to obtain a plurality of segmented pictures; A plurality of segmented pictures obtained by segmenting the image based on the image segmentation line in the first direction and a plurality of segmented pictures obtained by segmenting the image based on the image segmentation line in the second direction are determined as the at least one target detection picture.

4. The method according to claim 3, It is characterized in that Determining an image segmentation line of the webpage screenshot in the first direction according to the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot comprises: Determine the difference between each pixel value in each group of pixel values ​​in the first direction of the webpage screenshot; A representation sequence of the webpage screenshot in the first direction is obtained according to the difference of each group of pixel values; wherein a group of pixel values ​​corresponds to a position in the representation sequence, and adjacent groups are adjacent in position in the representation sequence, and when the difference of each group of pixel values ​​is less than a set difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a first value, and when the difference of each group of pixel values ​​is greater than or equal to the difference threshold, the sequence value of the position corresponding to each group of pixel values ​​is a second value, and the first value is different from the second value; An image segmentation line of the webpage screenshot in the first direction is determined according to the representation sequence.

5. The method according to claim 1 or 4, It is characterized in that Determining the difference between each pixel value in each group of pixel values ​​in the first direction in the webpage screenshot includes: For each group of pixel values, taking one pixel value in each group of pixel values ​​as a reference pixel value, obtaining the difference between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value; Based on the differences between the remaining pixel values ​​in each group of pixel values ​​and the reference pixel value, the difference of each group of pixel values ​​is obtained.

6. The method according to claim 4, It is characterized in that Determining an image segmentation line of the webpage screenshot in the first direction according to the representation sequence includes: Obtain a second number of intervals in the representation sequence where the sequence values ​​are consecutively the second value; Determining whether the second quantity is less than or equal to a set quantity threshold; If it is determined that the second number is greater than the set number threshold, the following loop process is performed until the second number is less than or equal to the set number value, and each loop process includes the following steps: For each interval in which the sequence value is continuously the second value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the first value to obtain a first updated sequence; For each interval in the updated representation sequence in which the sequence value is continuously the first value, if the length of the interval is less than or equal to the length threshold, the sequence value of the interval is set to the second value to obtain a second updated sequence; Determining whether a second quantity in the second update sequence is less than or equal to a set quantity threshold; If it is determined that the second number in the second update sequence is greater than the set number threshold, then the next cycle is entered; or, If it is determined that the second number in the second update sequence is less than or equal to the set number threshold, the loop ends.

7. A web page recognition device, It is characterized in that The device comprises: an acquisition unit, configured to acquire a webpage screenshot of the webpage to be identified according to the uniform resource locator URL of the webpage to be identified, and determine an image segmentation line of the webpage screenshot according to a difference between pixel values ​​of each row or column of the webpage screenshot; An image segmentation unit, used to segment the webpage screenshot according to the image segmentation line to obtain at least one target detection picture; a determination unit, configured to determine a probability that each target detection image in the at least one target detection image belongs to a target image type, and determine a probability that the web page to be identified belongs to a target web page type according to the probability of each target image; furthermore, when the probability that the web page to be identified belongs to a target web page type is greater than a set probability threshold, determine that the type of the web page to be identified is a target web page type; Among them, when the acquisition unit determines the image dividing line of the web page screenshot according to the difference between the pixel values ​​of each row or column of the web page screenshot, it is used to: determine the difference between each pixel value in each group of pixel values ​​in a first direction in the web page screenshot; wherein, the first direction is the row direction, and each group of pixel values ​​is a row of pixel values, or, the first direction is the column direction, and each group of pixel values ​​is a column of pixel values; when the difference of each group of pixel values ​​is less than a set difference threshold, determine that the pixel point corresponding to each group of pixel values ​​is the image dividing line of the web page screenshot.

8. A device for web page recognition, It is characterized in that The device comprises: A memory, used to store program instructions and page screenshots of the page access result page to be monitored; A processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods described in claims 1-6 according to the obtained program instructions.

9. A storage medium, It is characterized in that The storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the steps included in any one of the methods of claims 1-6.