Page anomaly detection method and device and storage medium

By constructing the document object model tree of the detection page and obtaining the attribute information of key elements, the problem of low page abnormality detection efficiency in the existing technology is solved, and fast and accurate page abnormality detection is achieved.

CN119396706APending Publication Date: 2025-02-07HANGZHOU HUACHENG SOFTWARE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411196321.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently detect page abnormalities, which affects the user experience and may lead to user churn.

Method used

By determining whether the document object model tree of the page to be detected is completed and obtaining attribute information of key elements in the document object model tree, we can judge whether there is an exception on the page based on this information.

Benefits of technology

This method can effectively reduce the time for information comparison, improve the efficiency of page abnormality detection, and ensure that page abnormality problems are detected and handled in a timely and accurate manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396706A_ABST
    Figure CN119396706A_ABST
Patent Text Reader

Abstract

The invention discloses a page anomaly detection method and device and a storage medium. The method comprises the steps that whether a document object model tree of a to-be-detected page is constructed or not is determined; in response to completion of construction of the document object model tree, obtaining attribute information of key elements in the document object model tree; and determining whether the to-be-detected page is abnormal or not based on the attribute information. In this way, the page anomaly detection efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to a page anomaly detection method, device and storage medium. Background Art

[0002] In modern front-end development, page anomalies are an important issue that affects the user experience. Page anomalies usually refer to situations where, when a user accesses a web page, the page appears completely blank, displays only the background color or other unexpected content. This phenomenon not only seriously affects the user experience, but may also lead to user loss. Therefore, timely and accurate detection of page anomalies is an important task that must be solved in front-end development. Summary of the invention

[0003] The main technical problem solved by the present application is to provide a page anomaly detection method, device and storage medium, which can improve the efficiency of page anomaly detection.

[0004] To solve the above technical problems, a technical solution adopted in the present application is: to provide a page anomaly detection method, the method comprising: determining whether the document object model tree of the page to be detected has been constructed; in response to the completion of the construction of the document object model tree, obtaining the attribute information of the key elements in the document object model tree; based on the attribute information, determining whether there is an anomaly in the page to be detected.

[0005] To solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, comprising a memory and a processor coupled to each other, the memory storing program instructions; the processor is used to execute the program instructions stored in the memory to implement the above method.

[0006] In order to solve the above technical problem, another technical solution adopted by the present application is: providing a computer-readable storage medium for storing program instructions, which can be executed to implement the above method.

[0007] The above scheme, after determining that the document object model tree of the page to be detected is constructed, determines whether the page to be detected has an abnormality by obtaining the attribute information of the key elements in the document object model tree. Among them, the attribute information of the key elements of the present application is the information directly contained in the constructed document object model tree. Compared with the method of comparing the information in the document object model tree with the preset data of the page and detecting whether the page is abnormal according to the comparison result, the method of using the information directly contained in the document object model tree to detect page anomalies in the present application can effectively reduce the time of information comparison, so it can improve the efficiency of anomaly detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1It is a flow chart of an embodiment of a page anomaly detection method provided by the present application;

[0009] Figure 2 yes Figure 1 The flowchart of step S13 is shown as an embodiment;

[0010] Figure 3 yes Figure 2 The flowchart of step S23 is shown as an embodiment;

[0011] Figure 4 It is a schematic diagram of the framework of an embodiment of a page anomaly detection device provided by the present application;

[0012] Figure 5 It is a schematic diagram of a framework of an embodiment of an electronic device provided by the present application;

[0013] Figure 6 It is a schematic diagram of the framework of the computer-readable storage medium provided by this application. DETAILED DESCRIPTION

[0014] In order to make the purpose, technical solution and effect of the present application clearer and more specific, the present application is further described in detail below with reference to the accompanying drawings and examples.

[0015] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0016] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of a page anomaly detection method provided by the present application. It should be noted that if there are substantially the same results, this embodiment does not take Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes:

[0017] S11: Determine whether the document object model tree of the page to be detected is constructed.

[0018] This embodiment is used to determine whether there is an abnormality in the page to be detected based on the attribute information of the key elements in the document object model tree.

[0019] The page to be detected in this application is the page to be accessed by the target object. The page rendering process includes: downloading page resources from the server, parsing the page resources through the browser to construct a DOM (Document Object Model) tree, and then accessing the DOM tree to render the page. The page resources include HTML (HyperText Markup Language), CSS (Cascading Style Sheets), JavaScript (scripts) and other resources; the constructed DOM tree is a tree representation of the document object model used by the browser, which contains all elements and attributes in the HTML document.

[0020] In one embodiment, determining whether the document object model tree of the page to be detected is completed includes: using the target attribute of the target script in the document of the page to be detected, monitoring the change status of the target attribute, and using a custom variable to track the loading status of the document; based on the change status of the target attribute and the loading status of the document, determining whether the document is parsed; in response to the completion of document parsing, determining that the document object model tree of the page to be detected is completed.

[0021] In one embodiment, the document is a document including the above-mentioned page resources, the target script is javascript, and the target attribute is the readyState attribute built into JavaScript.

[0022] When the page is loaded, you can use custom variables to track the loading status of the document, and use the JavaScript built-in readyState attribute to monitor the changes in readyState. When the document loading is tracked to be complete and the readyState changes from loading to complete, it indicates that the document parsing is complete. It should be noted that when the document parsing is completed, it indicates that the document object model tree of the detection page is built.

[0023] S12: In response to the document object model tree being constructed, obtaining attribute information of key elements in the document object model tree.

[0024] The key element is an element in the page that needs to be monitored, for example, a relatively important element in the page. In this embodiment, the number of the key element is at least one, which can be determined according to the importance of the element and the needs of the target object.

[0025] In one embodiment, step S12 includes: in response to the completion of the construction of the document object model tree, detecting the execution status of the target script in the document of the page to be detected; in response to the execution status of the target script being completed, triggering a predefined callback function, and the callback function is used to execute the step of obtaining the attribute information of the key elements in the document object model tree.

[0026] That is, in this case, the predefined callback function will be triggered only after the target script (JavaScript) is loaded and executed, so as to be able to execute the subsequent acquisition of the attribute information of the key elements in the document object model tree and the subsequent steps.

[0027] It should be noted that the above-mentioned pre-defined callback functions and customized variables can be configured through the standard Web API. Since the Web API is a basic interface, it is independent of the front-end framework and is easy to use, so it can be detected in different devices and browsers.

[0028] S13: Based on the attribute information, determine whether there is any abnormality in the page to be detected.

[0029] In one embodiment, it can be determined whether there is an abnormality in the attribute information of the key element. The attribute information is at least one of the visibility information, size information and content information of the element, and the rendering is performed according to the attribute information of the element during the rendering process. Exemplarily, if the visibility information of the element is element.style.display is none, and / or element.style.visi bility is hidden, then the element will not be rendered when the page is subsequently rendered; for example, if there is no size information or the size is 0, the target object cannot see the element from the final rendered page, and further, if the text content corresponding to the element is empty, the target object cannot see the text content corresponding to the element from the final rendered page. Therefore, in this embodiment, before the page is rendered, it can be determined whether the target object will be able to see the element in the page from the display screen in the future based on the attribute information of the key elements in the constructed DOM tree.

[0030] Therefore, in this implementation, if it is determined that the attribute information of the key element has any of the above-mentioned anomalies, it can be determined that the attribute information of the key element has an anomaly, and then it can be determined that the page to be detected has an anomaly, that is, when the attribute information of the key element has an anomaly, the page to be detected will also have a display anomaly in the future display screen. Among them, identifiers can be set in advance for the key elements that need to be monitored, and then the corresponding attribute information is searched from the DOM tree based on the identifiers corresponding to each key element. In one embodiment, among multiple key elements, as long as the attribute information corresponding to one of the key elements has an anomaly, it will be determined that the page to be detected has an anomaly, so the identifiers corresponding to different key elements can be set to be the same, that is, the identifier is only used to distinguish between key elements and non-key elements.

[0031] It should be noted that, since the DOM tree is a tree structure, the DOM tree has a root node and child nodes. In this embodiment, it can be determined first whether there is an abnormality in the attribute information of the root node in the DOM tree. If there is an abnormality in the attribute information of the root node, there is no need to detect the attribute information of the child nodes, and it can be directly determined that there is an abnormality in the page to be detected; but if there is no abnormality in the attribute information of the root node, it is determined whether there is an abnormality in the attribute information of the child nodes.

[0032] It should also be noted that, since the DOM tree is constructed before the page is rendered, after determining that there is no abnormality in the attribute information of the key elements, page abnormality detection should also be performed based on the rendered page.

[0033] Exemplarily, in one embodiment, if it is determined that there is no abnormality in the attribute information of the key element, the color value of each pixel in the page display screen can be determined, and based on the color value of each pixel, it is determined whether there is any abnormality in the page to be detected.

[0034] Among them, considering that obtaining the color values ​​of all pixels in the page display screen will cause screen information leakage, and it takes a long time to obtain all pixels in the page display screen, in order to improve the detection efficiency and protect the screen information from being leaked, some pixels can be selected from the page display screen as target pixels, and then based on the color values ​​of the target pixels, it is determined whether the page to be detected has an abnormality. For the specific implementation process, please refer to Figure 2 Description of the illustrated embodiment.

[0035] The above scheme, after determining that the document object model tree of the page to be detected is constructed, determines whether the page to be detected has an abnormality by obtaining the attribute information of the key elements in the document object model tree. Among them, the attribute information of the key elements of the present application is the information directly contained in the constructed document object model tree. Compared with the method of comparing the information in the document object model tree with the preset data of the page and detecting whether the page is abnormal according to the comparison result, the method of using the information directly contained in the document object model tree to detect page anomalies in the present application can effectively reduce the time of information comparison, so it can improve the efficiency of anomaly detection.

[0036] Furthermore, after the page is rendered, it can be determined whether the page to be detected has an abnormality based on the color value of the target pixel point in the page display screen. Compared with the method of using the entire page display screen to determine whether the page is abnormal, this application can effectively improve the detection efficiency of page anomalies and better protect the privacy of the target object.

[0037] See also Figure 2 , Figure 2 yes Figure 1 The flowchart of step S13 is shown as an embodiment. Figure 2 As shown, this embodiment includes:

[0038] S21: Determine whether there is any abnormality in the attribute information.

[0039] The specific implementation of step S21 can refer to the above description.

[0040] S22: In response to the fact that there is no abnormality in the attribute information, determine a target pixel point in the page display screen.

[0041] In this embodiment, there are multiple target pixels, and determining the target pixels in the page display screen includes the following steps:

[0042] First, the page display screen is divided into grids to obtain a plurality of first grids.

[0043] Second, target pixel points that meet preset position requirements are selected from each first grid.

[0044] Among them, in order to make each determined target pixel point represent the color distribution of the corresponding first grid and avoid edge effects, and at the same time to ensure the representativeness and uniformity of the target pixel point, the center point of each first grid, or any position point located in the central area of ​​each first grid can be used as the target pixel point.

[0045] In order to determine the position of each target pixel point in the page display screen, a screen coordinate system can be established in advance, and then the number of rows and columns to be divided into the grid is defined based on the height and width of the screen, and the page display screen is gridded according to the required number of rows and columns to obtain a plurality of first grids.

[0046] Exemplarily, in one embodiment, a screen coordinate system is established with the pixel point at the lower left corner of the screen as the origin, and the coordinates of each target pixel point can be determined using the following formula:

[0047] (x,y)=((i+0.5)×a,(j+0.5)×b)

[0048] Where (x, y) represents the coordinates of the target pixel, i and j represent the row and column numbers of the grid, respectively, both starting from 0; a represents the ratio of the screen width to the number of columns, and b represents the ratio of the screen height to the number of rows.

[0049] S23: Determine whether there is any abnormality in the page to be detected based on the color value of the target pixel.

[0050] In this embodiment, based on the color value of the target pixel, the number of abnormal pixels corresponding to the abnormal color value in the target pixel can be determined, and then based on the ratio of the abnormal pixels to the number of all pixels in the page display screen, it is determined whether there is an abnormality in the page to be detected.

[0051] Specifically, see Figure 3 , Figure 3 yes Figure 2 The flowchart of step S23 is shown as an embodiment. Figure 3 As shown, this embodiment includes:

[0052] S31: Determine a first number of abnormal pixels among a plurality of target pixels, wherein color values ​​of the abnormal pixels are not within a preset threshold range.

[0053] S32: Determine a ratio of the first number to the second number, wherein the second number is the number of all pixels in the page display screen.

[0054] S33: Based on the ratio, determine whether there is an abnormality in the page to be detected.

[0055] In this embodiment, before executing step S31, the color value of each target pixel needs to be determined. Specifically, the page content displayed by the target pixel can be described first, and then the color value of the target pixel can be determined using the described page content.

[0056] In a specific embodiment, a Canvas element can be created in the DOM and set to a hidden state to avoid affecting the page display of the page to be detected. In addition, the width and height of the Canvas are set to be consistent with the screen resolution to ensure that the entire screen content can be drawn. Further, the size of the Canvas is set to 1x1 pixels to ensure that only one pixel of data is drawn and obtained each time, avoiding the acquisition of redundant page content, and then the page content of each target pixel is drawn on the 1x1 pixel Canvas. By passing the document.body of the page and the coordinates of the target pixel, the page content of the target pixel is drawn on the Canvas, and the getImageData method of the Canvas is used to obtain the color value of the 1x1 pixel drawn on the Canvas (for example, at least part of the value in the RGBA value). In this way, the color value of the target pixel is obtained.

[0057] In one embodiment, in the process of determining whether there is an abnormality in the page to be detected based on the ratio of the first number to the second number, if the ratio is greater than a preset threshold, it can be directly determined that there is an abnormality in the page to be detected; if the ratio is not greater than the preset threshold, it is directly determined that there is no abnormality in the page to be detected.

[0058] In another embodiment, considering that the page display screen is divided into grids, the number of grids obtained is different, and the number of corresponding target pixels is also different. If the color values ​​of a small number of target pixels corresponding to a small number of grids can determine that the page to be detected has an abnormality, then no further detection is required; but if the color values ​​of a small number of target pixels cannot determine that the page to be detected has an abnormality, in order to avoid the situation where the page itself has an abnormality but a small number of target pixels are selected, causing false detection, on the basis of the first grid obtained by division, each first grid can be further divided to obtain a number of second grids; then each second grid is used as a new first grid, and new target pixels are re-determined based on the new first grids (the method for determining the target pixels can be referred to the description above), and the first number of abnormal pixels in the multiple target pixels and subsequent steps are re-executed until it is determined that the page to be detected has an abnormality, or the number of re-executions reaches a preset number.

[0059] If the number of the first and subsequent steps of determining the number of abnormal pixels among the plurality of target pixels reaches a preset number of times, and the ratio of the first number to the second number is still not greater than a preset threshold, it is determined that there is no abnormality in the page to be detected. The specific preset threshold and preset number of times can be determined according to actual needs and the expected detection accuracy.

[0060] The color values ​​of the above-mentioned target pixel points generally include red value, green value, blue value and transparency value, and each value corresponds to a preset threshold range. If all color values ​​of the target pixel points are within the corresponding preset threshold range, the color value of the target pixel point is considered normal, otherwise the color value of the target pixel point is considered abnormal, and the corresponding pixel point is an abnormal pixel point.

[0061] In summary, the embodiment of the present invention is to first divide the page display screen into coarse grids to obtain a number of coarse grids of larger size, wherein the number of target pixels is positively correlated with the number of grids. It is understandable that when some pages present obvious abnormalities, the color values ​​of the target pixels obtained from the coarse grids can be used to determine that the page to be detected has abnormalities. However, if the page has non-obvious abnormalities, due to the small number of selected target points, it may cause false detection. In this case, the coarse grids originally divided can be divided again to obtain a larger number of grids, and then more target pixels can be selected to reduce false detection. Of course, if the grids finally divided are fine enough and the number of target pixels is large enough, the page can be accurately detected using the large number of target pixels. At this time, the corresponding detection result can be used as the final detection result, that is, if the detection does not show abnormalities, it means that the page to be detected is normal, and if the detection shows abnormalities, it means that the page to be detected has abnormalities.

[0062] Of course, in scenarios where the detection efficiency is not high, the page display screen can be directly divided into fine grids to directly obtain a sufficient number of small grids. These small grids are then used to detect whether there is an abnormality on the page.

[0063] In some embodiments, after determining that an abnormality exists in the page to be detected, abnormality information may also be sent to the target object so that the target object can make corresponding processing based on the abnormality information.

[0064] In some embodiments, after determining that an abnormality exists in the page to be detected, the abnormality information can also be written into the log system, and combined with the response mechanism, an alarm can be quickly triggered to ensure that the abnormality can be responded to and handled in a timely manner.

[0065] In some embodiments, the tools used in the above detection method can be integrated into the SDK, so that the above page anomaly detection method can be executed later using a device with the SDK installed.

[0066] See also Figure 4 , Figure 4It is a schematic diagram of a framework of an embodiment of a page anomaly detection device provided by the present application. In this embodiment, the page anomaly detection device 40 includes a first determination module 41, an acquisition module 42 and a second determination module 43. The first determination module 41 is used to determine whether the document object model tree of the page to be detected has been constructed; the acquisition module 42 is used to obtain the attribute information of the key elements in the document object model tree in response to the completion of the document object model tree construction; the second determination module 43 is used to determine whether the page to be detected has an anomaly based on the attribute information.

[0067] In some embodiments, the second determination module 43 determines whether there is an abnormality in the page to be detected based on the attribute information, including: determining whether there is an abnormality in the attribute information; in response to the fact that there is no abnormality in the attribute information, determining the target pixel point in the page display screen; and determining whether there is an abnormality in the page to be detected based on the color value of the target pixel point.

[0068] In some embodiments, there are multiple target pixel points; determining the target pixel points in the page display screen includes: dividing the page display screen into grids to obtain a plurality of first grids; and selecting each target pixel point that meets the preset position requirements from each first grid.

[0069] In some embodiments, each target pixel point is a position center point corresponding to the first grid, or is any position point in the central area corresponding to the first grid.

[0070] In some embodiments, there are multiple target pixels; based on the color values ​​of the target pixels, determining whether there is an abnormality in the page to be detected includes: determining a first number of abnormal pixels among the multiple target pixels, wherein the color values ​​of the abnormal pixels are not within a preset threshold range; determining a ratio of the first number to the second number, wherein the second number is the number of all pixels in the page display screen; based on the ratio, determining whether there is an abnormality in the page to be detected.

[0071] In some embodiments, multiple target pixel points are pixel points that meet preset position requirements and are selected from a number of first grids, respectively, and the number of first grids are obtained by gridding the page display screen; based on the ratio, determining whether there is an abnormality in the page to be detected, including: in response to the ratio being greater than a preset threshold, determining that there is an abnormality in the page to be detected; in response to the ratio being not greater than the preset threshold, gridding each first grid to obtain a number of second grids; and using each second grid as a new first grid, re-determining new target pixel points based on each new first grid, and re-executing the first number of abnormal pixel points in the multiple target pixel points and subsequent steps until it is determined that there is an abnormality in the page to be detected, or the number of re-executions reaches a preset number; wherein, when the number of times the first number of abnormal pixel points in the multiple target pixel points and subsequent steps are re-executed reaches a preset number, if the ratio is not greater than the preset threshold, it is determined that there is no abnormality in the page to be detected.

[0072] In some embodiments, before determining whether the page to be detected has an abnormality based on the color value of the target pixel, the method further includes: depicting the page content displayed by the target pixel; and determining the color value of the target pixel using the depicted page content.

[0073] In some embodiments, the number of key elements is at least one, and the attribute information of each key element includes at least one of visibility information, size information and content information; the second determination module 43 determines whether there is an abnormality in the page to be detected based on the attribute information, including: determining whether there is an abnormality in the attribute information of each key element; in response to the existence of an abnormality in the attribute information, determining that there is an abnormality in the page to be detected; wherein, if there is an abnormality in any of the attribute information, it is determined that there is an abnormality in the attribute information; and / or, the attribute information of each key element is obtained by searching based on the identifier of the corresponding key element.

[0074] In some embodiments, the first determination module 41 determines whether the document object model tree of the page to be detected is constructed, including: using the target attribute of the target script in the document of the page to be detected, monitoring the change state of the target attribute, and using a custom variable to track the loading state of the document; based on the change state of the target attribute and the loading state of the document, determining whether the document is parsed; in response to the completion of document parsing, determining that the document object model tree of the page to be detected is constructed;

[0075] And / or, the acquisition module 42 acquires the attribute information of the key elements in the document object model tree in response to the completion of the construction of the document object model tree, including: in response to the completion of the construction of the document object model tree, detecting the execution status of the target script in the document of the page to be detected; in response to the execution status of the target script being completed, triggering a predefined callback function, the callback function being used to execute the step of acquiring the attribute information of the key elements in the document object model tree;

[0076] And / or, after the second determination module 43 determines whether the page to be detected has an abnormality based on the attribute information, the method further includes: in response to the page to be detected having an abnormality, sending abnormality information to the target object.

[0077] See also Figure 5 , Figure 5 1 is a schematic diagram of a framework of an electronic device according to an embodiment of the present application. In this embodiment, the electronic device 50 includes a memory 51 and a processor 52 coupled to each other.

[0078] The memory 51 stores program instructions, and the processor 52 is used to execute the program instructions stored in the memory 51 to implement the steps of any of the above method implementations. In a specific implementation scenario, the electronic device 50 may include, but is not limited to: a microcomputer, a server, and in addition, the electronic device 50 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.

[0079] Specifically, the processor 52 is used to control itself and the memory 51 to implement the steps of any of the above-mentioned embodiments. The processor 52 can also be called a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip with signal processing capabilities. The processor 52 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 52 can be implemented by an integrated circuit chip.

[0080] See also Figure 6 , Figure 6It is a schematic diagram of the framework of the computer-readable storage medium provided by the present application. The computer-readable storage medium 60 of the embodiment of the present application stores a program instruction 61, and when the program instruction 61 is executed, the method provided by any embodiment of the above method and any non-conflicting combination is implemented. Among them, the program instruction 61 can form a program file and be stored in the above-mentioned computer-readable storage medium 60 in the form of a software product, so that a computer device (which can be a personal computer, a server, or a network device, etc.) executes all or part of the steps of each implementation method of the present application. The aforementioned computer-readable storage medium 60 includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, or a terminal device such as a computer, a server, a mobile phone, and a tablet.

[0081] The above scheme, after determining that the document object model tree of the page to be detected is constructed, determines whether the page to be detected has an abnormality by obtaining the attribute information of the key elements in the document object model tree. Among them, the attribute information of the key elements of the present application is the information directly contained in the constructed document object model tree. Compared with the method of comparing the information in the document object model tree with the preset data of the page and detecting whether the page is abnormal according to the comparison result, the method of using the information directly contained in the document object model tree to detect page anomalies in the present application can effectively reduce the time of information comparison, so it can improve the efficiency of anomaly detection.

[0082] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0083] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0084] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0085] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0086] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0087] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0088] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A page anomaly detection method, characterized in that: The method comprises: Determine whether the document object model tree of the page to be detected is built; In response to the document object model tree being constructed, acquiring attribute information of key elements in the document object model tree; Based on the attribute information, determine whether the page to be detected has an abnormality.

2. The method according to claim 1, characterized in that The determining whether the page to be detected has an abnormality based on the attribute information includes: Determine whether the attribute information is abnormal; In response to the attribute information not being abnormal, determining a target pixel point in the page display screen; Based on the color value of the target pixel, it is determined whether the page to be detected has an abnormality.

3. The method according to claim 2, characterized in that The number of the target pixel points is multiple; The step of determining a target pixel point on a page display screen includes: Dividing the page display screen into grids to obtain a plurality of first grids; The target pixel points that meet the preset position requirements are selected from the first grids respectively.

4. The method according to claim 3, characterized in that: Each of the target pixel points is a position center point corresponding to the first grid, or is any position point in a central area corresponding to the first grid.

5. The method according to claim 2 or 3, characterized in that: The number of the target pixel points is multiple; The determining whether the page to be detected has an abnormality based on the color value of the target pixel point includes: Determining a first number of abnormal pixels among the plurality of target pixels, wherein the color values ​​of the abnormal pixels are not within a preset threshold range; Determine a ratio of the first number to a second number, wherein the second number is the number of all pixels in the page display screen; Based on the ratio, it is determined whether the page to be detected has an abnormality.

6. The method according to claim 5, characterized in that The plurality of target pixel points are pixel points that meet preset position requirements and are respectively selected from a plurality of first grids, and the plurality of first grids are obtained by gridding the page display screen; The determining, based on the ratio, whether the page to be detected has an abnormality includes: In response to the ratio being greater than a preset threshold, determining that an abnormality exists in the page to be detected; In response to the ratio being not greater than the preset threshold, each of the first grids is grid-divided to obtain a plurality of second grids; and each of the second grids is used as a new first grid, and a new target pixel is re-determined based on each of the new first grids, and the first number of abnormal pixel points among the plurality of target pixel points and subsequent steps are re-executed until it is determined that the page to be detected has an abnormality, or the number of re-executions reaches a preset number; wherein, when the number of times the first number of abnormal pixel points among the plurality of target pixel points and subsequent steps are re-executed reaches the preset number, if the ratio is not greater than the preset threshold, it is determined that the page to be detected has no abnormality.

7. The method according to claim 2, characterized in that Before determining whether the page to be detected has an abnormality based on the color value of the target pixel, the method further includes: Describing the page content displayed by the target pixel point; The color value of the target pixel is determined by using the depicted page content.

8. The method according to claim 1, characterized in that The number of the key elements is at least one, and the attribute information of each key element includes at least one of visibility information, size information and content information; The determining whether the page to be detected has an abnormality based on the attribute information includes: determining whether the attribute information of each of the key elements has an abnormality; in response to the attribute information having an abnormality, determining that the page to be detected has an abnormality; wherein if any of the attribute information has an abnormality, determining that the attribute information has an abnormality; And / or, the attribute information of each of the key elements is obtained by searching based on the identifier corresponding to the key element.

9. The method according to claim 1, characterized in that: The step of determining whether the document object model tree of the page to be detected is constructed includes: Using the target attribute of the target script in the document of the page to be detected, monitoring the change state of the target attribute, and using a custom variable to track the loading state of the document; Determining whether parsing of the document is complete based on the change state of the target attribute and the loading state of the document; In response to the document parsing being completed, determining that the document object model tree of the to-be-detected page is constructed; And / or, in response to the document object model tree being constructed, obtaining attribute information of key elements in the document object model tree includes: In response to the document object model tree being constructed, detecting the execution status of the target script in the document of the page to be detected; In response to the target script being executed in a completed state, triggering a predefined callback function, the callback function being used to execute the step of obtaining the attribute information of the key element in the document object model tree; And / or, after determining whether the page to be detected has an abnormality based on the attribute information, the method further includes: In response to the existence of an abnormality in the page to be detected, abnormality information is sent to the target object.

10. An electronic device, characterized in that: comprising a memory and a processor coupled to each other, The memory stores program instructions; The processor is used to execute the program instructions stored in the memory to implement the method according to any one of claims 1 to 9.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions that can be run by a processor, and the program instructions can be executed by the processor to implement the method according to any one of claims 1 to 9.