Data processing method and device, electronic equipment and storage medium
By filtering subtrees in response to user interaction events in web pages and adopting a dual identification strategy, the problem of unsatisfactory advertisement blocking effect in static filtering strategies is solved, and accurate identification and filtering of interference information is achieved.
Patent Information
- Application Number
- CN202510604785.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-09-23
AI Technical Summary
In the prior art, when a single static filtering strategy is used to intercept interference information such as advertisements, missed detections are likely to occur, resulting in unsatisfactory advertisement interception effects.
By responding to user interaction events, the subtree that matches the event attribute information is filtered from the structure tree of the web page, the web page elements to be identified are dynamically determined, and a dual identification strategy (behavior identification and content identification) is used to accurately identify and block interference information.
It improves the recognition effect of interference information such as advertisements, avoids the problem of missed judgment caused by a single recognition strategy, and realizes the accurate filtering of interference information in web pages.
Smart Images

Figure CN120687660A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data processing method, device, electronic device, and storage medium. Background Art
[0002] With the explosive growth of online information, the amount and types of data contained in web pages are also increasing. Among them, there may be interference information such as advertisements, which may affect the normal browsing of users.
[0003] In related technologies, static filtering strategies are usually used to filter and intercept interference information such as advertisements. For example, feature tags such as keywords corresponding to advertisements can be collected in advance, and then interception can be performed based on the feature tags.
[0004] However, the above method has great limitations. It is easy to miss detections by relying solely on a single static filtering strategy, resulting in unsatisfactory ad blocking effects. Summary of the Invention
[0005] The present disclosure provides a data processing method, device, electronic device and storage medium, which can improve the recognition effect of interference information such as advertisements.
[0006] In a first aspect, the present disclosure provides a data processing method, the method comprising:
[0007] In response to a user interaction event triggered on a web page, a subtree matching event attribute information of the user interaction event is selected from a plurality of subtrees included in a structure tree of the web page; wherein the structure tree is used to represent a plurality of web page sub-regions in the web page, and the subtrees are used to represent web page elements in the web page sub-regions;
[0008] Determining the web page element to be identified in the web page according to the matched subtree;
[0009] Obtaining a trigger operation corresponding to the webpage element to be identified, identifying the trigger operation using a first strategy to obtain a first identification result; performing content identification on the webpage element to be identified using a second strategy to obtain a second identification result;
[0010] When it is determined according to the first recognition result and the second recognition result that the webpage element to be recognized contains interference information, shielding processing is performed on the webpage element to be recognized.
[0011] In a second aspect, the present disclosure provides a data processing device, the data processing device comprising:
[0012] a screening module adapted to, in response to a user interaction event triggered on a web page, screen a subtree matching event attribute information of the user interaction event from a plurality of subtrees included in a structure tree of the web page; wherein the structure tree is used to represent a plurality of web page sub-regions in the web page, and the subtrees are used to represent web page elements in the web page sub-regions;
[0013] a determination module, adapted to determine a webpage element to be identified in the webpage according to the matched subtree;
[0014] an identification module adapted to obtain a trigger operation corresponding to the web page element to be identified, identify the trigger operation using a first strategy to obtain a first identification result, and perform content identification on the web page element to be identified using a second strategy to obtain a second identification result;
[0015] The processing module is adapted to perform shielding processing on the web page element to be identified when it is determined that the web page element to be identified contains interference information according to the first identification result and the second identification result.
[0016] In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor to enable the at least one processor to perform the above-mentioned data processing method.
[0017] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned data processing method when executed by a processor.
[0018] In a fifth aspect, the present disclosure provides a computer program product comprising a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned data processing method.
[0019] In the data processing method provided by the embodiment of the present disclosure, it is possible to dynamically screen the subtrees that match the event attribute information of the user interaction event from the multiple subtrees contained in the structure tree of the network page according to the user interaction event triggered by the user on the network page, and dynamically determine the web page elements to be identified based on the subtrees that match the event attribute information of the user interaction event, and perform dual identification through the first strategy and the second strategy, so as to accurately identify the interference information in the network page and perform shielding processing. It can be seen that, on the one hand, this method can dynamically determine the web page elements to be identified in combination with the user interaction event, so as to facilitate the key identification of elements closely related to the user operation and improve the identification effect; on the other hand, the comprehensiveness of the identification is improved through the dual identification strategy (the first strategy and the second strategy), avoiding the problem of inaccurate identification and omission due to a single identification strategy.
[0020] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings. In the accompanying drawings:
[0022] Figure 1 An application scenario diagram of the data processing method and device provided in the embodiments of the present disclosure;
[0023] Figure 2 A flowchart of a data processing method provided in an embodiment of the present disclosure;
[0024] Figure 3 A block diagram of a data processing device provided in an embodiment of the present disclosure;
[0025] Figure 4 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] To enable those skilled in the art to better understand the technical solutions of the present disclosure, exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0027] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0028] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0029] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. Similar words such as "connected" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0030] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined as such herein.
[0031] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The use of user data in this technical solution complies with relevant national laws and regulations (for example, the "Information Security Technology Personal Information Security Specification", etc.). For example: corresponding prescribed measures are taken to control access to personal information; the display of personal information is subject to prescribed restrictions; the purpose of using personal information does not exceed the scope of direct or reasonable connection; when using personal information, clear identity reference is eliminated to avoid precise positioning of specific individuals.
[0032] In related technologies, static filtering strategies are usually used to filter and intercept interference information such as advertisements. For example, feature tags such as keywords corresponding to advertisements can be collected in advance, and then intercepted based on the feature tags. However, the above method has great limitations. It is easy to miss judgments by using only a single static filtering strategy, resulting in unsatisfactory advertisement interception effects. In order to solve the above problems, the present disclosure provides a data processing method, device, electronic device and storage medium. This method dynamically determines the web page elements to be identified in combination with user interaction events, which can improve the recognition effect, and can improve the comprehensiveness of recognition through a dual recognition strategy.
[0033] Figure 1 This is an application scenario diagram of the data processing method and device provided in the embodiments of the present disclosure.
[0034] like Figure 1 As shown, an application scenario of an embodiment of the present disclosure may include a terminal device 101, a network 103, and a server 102. The network 103 is used as a medium for providing a communication link between the terminal device 101 and the server 102. The network 103 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0035] The user can use the terminal device 101 to interact with the server 102 through the network 103 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (only as examples). The terminal device 101 can be various electronic devices with a display screen and support web browsing, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers, etc. Server 102 can be a server that provides various services, such as a background management server (only as an example) that provides support for the website browsed by the user using the terminal device 101. The background management server can analyze the data such as the user request received, and feed back the processing result (such as the web page, information, or data obtained or generated according to the user request, etc.) to the terminal device.
[0036] It should be noted that the data processing method and apparatus provided in the embodiments of the present disclosure can be executed by the server 102 or the terminal device 101. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server can be an independent physical server, a server cluster consisting of multiple physical servers, or a cloud server capable of cloud computing. The method can be implemented by a processor calling computer-readable program instructions stored in a memory.
[0037] Figure 2 A flowchart of a data processing method provided by an embodiment of the present disclosure. Figure 2 , the method comprising:
[0038] Step S210: In response to a user interaction event triggered on a web page, a subtree matching the event attribute information of the user interaction event is filtered from a plurality of subtrees included in a structure tree of the web page; wherein the structure tree is used to represent a plurality of web page sub-areas in the web page, and the subtrees are used to represent web page elements in the web page sub-areas.
[0039] This step aims to trigger subtree screening through user interaction events, thereby achieving accurate positioning and processing of web page interference information. Among them, the web page can be various web pages, such as static web pages, dynamic web pages, etc. This application does not limit the type and content of the web page. User interaction events refer to: interaction events generated by users with web pages through interactive portals such as mouse, keyboard or touch screen, including but not limited to the following: (1) click: a single press operation of a mouse or touch device; (2) hover: the cursor stays in a certain area for more than a threshold time (such as 1 second); (3) scroll: the scrolling cursor causes the page to produce vertical or horizontal displacement.
[0040] A structure tree, also called a page structure tree, can be a hierarchical data structure used to characterize the visual and logical partitioning of a web page (represented by multiple web page sub-areas). For example, it can be generated by parsing the Document Object Model (DOM): converting a HyperText Markup Language (HTML) document into a node tree, retaining tags, attributes, and nested relationships. Accordingly, the structure tree can specifically be a DOM tree. For another example, it can be generated based on a visual block-based approach: dividing a web page into multiple independent sub-areas (such as headers, advertising columns), etc. based on element layout (such as position and size), and characterizing the characteristics of each independent sub-area through a structure tree. A subtree can be a collection of child nodes in a structure tree, corresponding to an independent function or visual block in a web page. There are multiple ways to divide a subtree, for example, it can be divided according to tags and attributes in the DOM. Optionally, a subtree can contain one or more elements.
[0041] As can be seen, the structure tree contains multiple subtrees, each of which represents web page elements within a corresponding subregion of the web page. Accordingly, the subtree that matches the event attribute information of a user interaction event is the subtree associated with the user interaction event. Specifically, this refers to a subtree that has an action and / or influence relationship with the user interaction event, i.e., a subtree that has a correlation and influence with the operation location or operation method of the user interaction event. As can be seen, association primarily includes direct action and indirect influence.
[0042] Among them, the event attribute information of the user interaction event is used to characterize the event source attributes of the user interaction event, such as event triggering time, event triggering position, event propagation path, event propagation level, event impact range, etc. The present application does not limit the specific connotation of the event attribute information. For example, it can be characterized in the form of the triggering position of the interaction event (such as the corresponding position information when the event is triggered), the event propagation level (such as propagation of one or more layers), functional dependencies, etc. Correspondingly, the match with the event attribute information of the user interaction event can be determined specifically by position comparison, area detection, etc. For example, if the position information corresponding to the subtree is the same as the position information corresponding to the event propagation path of the user interaction event, or the local area corresponding to the subtree is the same as the local area corresponding to the event propagation path of the user interaction event, then the two are considered to match. It can be seen that the event attribute information can also be represented by the event propagation path or the event impact area, which is used to describe the local area in the structure tree that is affected by the user interaction event.
[0043] In an optional manner, the subtree that matches the event attribute information of the user interaction event can be the subtree directly affected by the user interaction event: specifically, it can be determined whether the location information of the user interaction event overlaps with the location range of the DOM container corresponding to the subtree, or, based on the event bubbling mechanism, it can be determined whether the target element of the interaction event is a child node of a subtree root node. For example, the subtree that matches the event attribute information of the user interaction event can be filtered based on the interaction position, so that the subtree that matches the interaction position corresponding to the user interaction event is used as the subtree that matches the event attribute information of the user interaction event. For example, when a user interaction event is detected, the location information of the user interaction event in the web page can be obtained through a callback function. The location information can be specifically represented by the distance between the event triggering position and the page border of the web page (specifically, it can include a first distance relative to the top page border, a second distance relative to the bottom page border, a third distance relative to the left page border, and a fourth distance relative to the right page border). Accordingly, each subtree also has corresponding location information (which can also be represented by the distance between the element corresponding to the subtree and the page border of the web page). Therefore, by matching the event location information with the subtree location information, the subtree that matches the event attribute information of the user interaction event can be determined. For example, we can filter subtrees that match the event attribute information of user interaction events based on the event bubbling path: Using the event bubbling mechanism, we traverse the event propagation path and determine the subtrees that match the event attribute information of the user interaction event based on the subtree root nodes that match the propagation path. For example, if a user enters text in the comment area, the subtree of the comment area to which the input box belongs is the matching subtree.
[0044] In another optional way, the subtree that matches the event attribute information of the user interaction event can also be the subtree indirectly affected by the user interaction event: for example, the correlation judgment can be made based on the functional dependency relationship. When the sub-area function corresponding to the subtree has a logical dependency on the user operation, even if the user does not directly interact with the subtree, the subtree is still regarded as a matching subtree. For example, after the user submits a form, the subtree corresponding to the form submission result prompt area is regarded as the subtree that matches the submission operation. For another example, if the subtree content depends on the data generated by the user operation, the subtree that has a dependency relationship with the user operation is the matching subtree. For example, if the user selects a product category, the product list subtree is the matching subtree.
[0045] In summary, the definition criteria for matching event attribute information with user interaction events can be represented in a variety of ways, such as spatial location, DOM hierarchy, and functional dependency.
[0046] In addition, subtree screening can also be performed based on interaction hot zone analysis: historical interaction data (such as click heat maps) are counted, and high-frequency operation areas are marked as "hot zone subtrees", thereby determining "hot zone subtrees" as subtrees associated with user interaction events.
[0047] Step S220: Determine the web page element to be identified in the web page according to the matched subtree.
[0048] Through user interaction events, it is possible to accurately locate subtrees with high or more important user attention, avoiding the time-consuming and untimely interception problems caused by the subsequent analysis of the full quantum tree. Accordingly, in this step, the web page elements to be identified in the network page can be determined based on the matched subtrees. Among them, the number of matched subtrees can be one or more, and accordingly, all elements contained in the matched subtrees can be directly used as web page elements to be identified, or elements of preset types can be extracted from the matched subtrees as web page elements to be identified. This application does not limit the specific details. For example, the web page elements to be identified can be atomic-level components in the subtree that need to be interfered with by analysis, such as text blocks, pictures, videos, buttons and other user-perceivable entities (i.e., visible elements), or advertising containers, delayed-loaded pop-up scripts, etc. (i.e., hidden elements). Through the correlation constraints between user interaction events, only elements that are logically associated with the user's current interaction (such as advertisements triggered after clicking a button) can be processed in subsequent steps, thereby narrowing the processing scope and improving processing efficiency.
[0049] Optionally, we can use a subtree backtracking method to determine the web page elements to be identified: starting from the root node of the associated subtree (i.e., the matching subtree), we traverse all its child elements and sort them by priority (e.g., elements with a visual percentage greater than 20% are prioritized). This method ensures comprehensive element detection and avoids missing deeply nested elements.
[0050] Step S230: Acquire the trigger operation corresponding to the web page element to be identified, identify the trigger operation using the first strategy to obtain a first identification result; perform content identification on the web page element to be identified using the second strategy to obtain a second identification result.
[0051] This step aims to improve the accuracy of the recognition results through a dual recognition strategy. The trigger operation corresponding to the web page element to be identified can be an operation triggered by the user on the web page element within a preset period of time (such as a click triggered by the user on the element), or an operation automatically triggered by the web page element (such as an operation automatically triggered by the element in the background). Accordingly, the first strategy is used to identify the trigger operation corresponding to the web page element to determine whether the trigger operation is abnormal. The first strategy can also be called a behavior recognition strategy, which is used to identify from the perspective of user behavior (corresponding to user trigger operation) and / or element behavior (corresponding to element trigger operation). Specifically, it can be a set of algorithms that infer the interference of elements based on user interaction patterns, and can include at least one of the following strategies: (1) Timing analysis strategy: Counting the user operation density during element exposure; (2) Trajectory modeling strategy: Analyzing the spatial relationship between the cursor movement path and the element layout. In short, the first strategy is used to identify abnormal behavior from aspects such as user behavior and element behavior, and thus make judgments based on the recognition results. For example, interactive advertisements such as floating advertisements and video advertisements can be identified by behavioral features such as mouse hover time, click-through rate, and automatic play. For example, if the ratio of the element's visible time to the total page dwell time is lower than a preset value, such as 5%, it can be determined to be a low-attention distraction, thereby eliminating floating ads that users may not have intended to view. Furthermore, the user's operation density (clicks / second) in the element area can be counted. If it exceeds a threshold (such as 3 times / second) and the distribution is irregular, it is determined to be a false touch, thereby identifying user errors caused by ad obstruction.
[0052] The second strategy, which can also be called a content identification strategy, is used to identify from the perspective of web page content. Specifically, it can be a set of rules for determining interference based on the internal data of the element. For example, it can be identified through text semantic features such as keyword matching and sentiment polarity analysis, or it can be identified based on visual features such as image size and color distribution. It can also be identified based on structural features such as HTML tag type and class name / ID naming rules. In specific implementation, a multimodal fusion detection method can be used for content identification. For example, multimedia content such as text, images, and audio can be jointly analyzed to improve the recognition ability of various types of advertisements such as rich media. Among them, rich media is a multimedia communication form that can integrate animation, sound, video and interactive information, and is widely used in application scenarios such as online advertising. Rich media refers to an interactive multimedia form that enhances the information transmission effect through various technical means. Its core feature is multimedia fusion: integrating elements such as text, images, audio, and video. Accordingly, the second strategy can effectively identify various content elements in dynamic advertisements such as rich media. Of course, this application can identify various types of interference information, not limited to rich media type advertisements.
[0053] Step S240: When it is determined according to the first recognition result and the second recognition result that the webpage element to be recognized contains interference information, shielding processing is performed on the webpage element to be recognized.
[0054] Among them, interference information generally refers to various information that users do not need, that is, information that interferes with the user's browsing process. For example, information that users actively avoid (such as quickly closing) or frequently touch can be regarded as interference information, and information containing advertising promotion, false inducement or security threats (such as malicious scripts) can also be regarded as interference information. When making a specific judgment, the first recognition result and the second recognition result can be weightedly fused, and whether shielding is required can be determined based on the fusion result. Shielding processing can include various methods such as interception processing and deletion processing, as long as the impact on the user can be reduced.
[0055] This approach enables precise filtering of interference information through a dual-dimensional recognition mechanism (behavior and content) and dynamic judgment rules. It first narrows the detection range through subtree correlation, and then deeply identifies the target element to improve processing efficiency.
[0056] It can be seen that in the data processing method provided by the embodiment of the present disclosure, it is possible to dynamically screen the subtrees associated with the user interaction events from the multiple subtrees contained in the structure tree of the network page according to the user interaction events triggered by the user on the network page, and dynamically determine the web page elements to be identified according to the subtrees that match the event attribute information of the user interaction events, and perform dual identification through the first strategy and the second strategy, so as to accurately identify the interference information in the network page and perform shielding processing. It can be seen that, on the one hand, this method can dynamically determine the web page elements to be identified in combination with the user interaction events, so as to facilitate the key identification of elements closely related to user operations and improve the identification effect; on the other hand, the comprehensiveness of the identification is improved through the dual identification strategy (the first strategy and the second strategy), avoiding the problem of inaccurate identification and omission due to a single identification strategy.
[0057] In addition, those skilled in the art may also make various changes and modifications to the methods in the embodiments of the present disclosure:
[0058] In an optional implementation, considering that static subtree division cannot adapt to dynamic content loading (such as infinite scrolling), which may lead to a decrease in the relevance of subsequent operations, in order to improve the accuracy of subtree division, the subtree division method can be dynamically adjusted according to the user interaction event. Accordingly, when screening the subtree that matches the event attribute information of the user interaction event from the multiple subtrees contained in the structure tree of the web page, it can be achieved in the following way: when the event type of the user interaction event matches the preset adjustment type, the subtree corresponding to the user interaction event is determined from the structure tree of the web page; the subtree division method of the subtree corresponding to the user interaction event is adjusted to obtain an adjusted structure tree, so that the subtree that matches the event attribute information of the user interaction event is screened from the multiple subtrees contained in the adjusted structure tree. This method can solve the problem of low processing efficiency caused by the mismatch between the subtree division method and the user intention through the preset adjustment type matching mechanism and the dynamic subtree structure adjustment strategy, thereby accurately adapting to the user intention and dynamically selecting the merge or split strategy according to the event type. On the one hand, it can reduce the computational overhead of non-correlated areas, and on the other hand, it can focus on key areas for key recognition and improve recognition accuracy. In summary, adjusting the subtree structure can improve the accuracy and speed of subsequent recognition. Preset adjustment types can be determined based on predefined interaction operation classification rules and used to trigger adjustments to the subtree division method. For example, in cases of rapid scrolling or prolonged periods of no interaction, the processing granularity can be reduced by merging subtrees; in cases of hovering and high-frequency false touches, the processing granularity can be refined by splitting subtrees. This shows that this method can compare the user's current interaction characteristics (such as operation frequency and trajectory pattern) with the preset adjustment type, thereby dynamically triggering subtree adjustment processing. The subtree corresponding to a user interaction event can be determined in a variety of ways. For example, to improve processing efficiency, the scope and number of subtrees corresponding to the user interaction event can be expanded as much as possible: all subtrees within a specified area adjacent to the event trigger location of the user interaction event are used as the subtree corresponding to the user interaction event, and the area range of this specified area can be flexibly adjusted. For another example, to reduce the amount of computation, the scope and number of subtrees corresponding to the user interaction event can be minimized: only the subtree belonging to the event trigger location of the user interaction event is used as the subtree corresponding to the user interaction event. In addition, in addition to determining the subtree corresponding to the user interaction event based on the event trigger location, the scope of the subtree that needs to be adjusted can also be determined by factors such as the event attribute information of the user interaction event, the event propagation path, and / or the event impact range. This application does not limit the specific implementation details, as long as the dynamic adjustment of the structure tree can be achieved.
[0059] In an optional implementation, the preset adjustment type may include: a first adjustment type and a second adjustment type. Accordingly, adjusting the subtree division method of the subtree corresponding to the user interaction event includes: if the event type of the user interaction event matches the first adjustment type, performing a merge adjustment on the subtree division method of the subtree corresponding to the user interaction event so as to reduce the number of subtrees of the subtree corresponding to the user interaction event; if the event type of the user interaction event matches the second adjustment type, performing a split adjustment on the subtree division method of the subtree corresponding to the user interaction event so as to increase the number of subtrees of the subtree corresponding to the user interaction event. Among them, the merge adjustment is used to merge multiple subtrees into a set of child nodes under the same parent node, aiming to merge at least two subtrees to reduce the number of subtrees and reduce computational overhead by increasing the processing granularity. The split adjustment is used to split a single subtree into multiple independent subtrees according to child nodes or visual blocks, aiming to perform fine-grained splitting on a subtree to increase the number of subtrees and achieve fine-grained recognition by reducing the processing granularity.
[0060] Optionally, the first adjustment type may include: a sliding event type in which the sliding speed exceeds a preset speed threshold, and / or an interaction event type in which the interaction frequency is less than a first frequency threshold. For example, if the user slides quickly, it means that the user is not interested in the current content. Therefore, there is no need for fine-grained splitting processing, and the analysis time can be reduced by merging subtrees. For another example, if the user's interaction frequency within a specified time period is low, multiple subtrees of the corresponding area can be merged. The second adjustment type may include: a mouse hover event type in which the hover duration is greater than a preset hover threshold, and / or an interaction event type in which the interaction frequency is greater than a second frequency threshold. User behavior of the second adjustment type indicates the need to improve analysis accuracy and focus on potential interference areas. For example, if the mouse stays in a subtree area for a time greater than a threshold (such as 2 seconds), the subtree is split into finer-grained units; for another example, if the user clicks on a certain area more than 3 times in a row and there is no effective response to the click target (such as no jump or pop-up window), the subtree is split to locate hidden advertising elements.
[0061] In an optional implementation, the web page is a dynamic web page, and the content or layout of the dynamic web page can change in real time with user operations, data loading or script execution. In order to ensure that the structure tree matches the updated dynamic web page, when a change in the web page is detected, the area in the web page that has changed (such as a local area) can be determined, and at least one subtree associated with the changed area in the structure tree of the web page can be updated by incremental update. Among them, the attribute or structural changes of the subtree nodes can be monitored by DOM change monitoring to trigger local update processing. Among them, the changed area can be a continuous block in the dynamic web page where the structure or content changes. Incremental update means: only the subtree corresponding to the changed area is partially rebuilt, rather than the full refresh of the structure tree. For example, specific attributes or subnodes in the subtree can be modified through node-level updates (such as text content changes); for example, subtree nodes can be added or deleted (such as new comment list items) through structure-level updates.
[0062] Correspondingly, the web page elements to be identified in the network page can be further determined based on at least one subtree updated within a preset time period, so that the web page elements to be identified are determined based on the recently updated subtree, thereby focusing on identifying the updated area. Among them, the preset time period is a sliding time window used to limit the range of elements to be identified (such as the subtree updated within the last 5 seconds), which can be a fixed window or a dynamic window (for example, it can be dynamically adjusted according to the page load, such as shortening the time window when concurrency is high). Through dynamic monitoring and incremental update mechanisms, the efficiency bottleneck of fully rebuilding the structure tree can be avoided. Moreover, by only updating the locally changed areas, the time consumption of subtree updates can be greatly reduced. Moreover, the web page elements to be identified can be filtered based on the updated subtrees of the preset time period to ensure that high-priority areas are processed first.
[0063] In an optional implementation, determining whether the web page element to be identified contains interference information based on the first recognition result and the second recognition result includes: performing weight processing on the first recognition result and the second recognition result based on the first strategy weight of the first strategy and the second strategy weight of the second strategy, and determining whether the web page element to be identified contains interference information based on the weight processing result. Among them, the first strategy weight (also called the behavior strategy weight) is used to characterize the contribution ratio of the first recognition result (also called the behavior recognition result) in the comprehensive judgment, reflecting the priority of the user interaction mode to the interference judgment. The second strategy weight (also called the content strategy weight) is used to characterize the contribution ratio of the second recognition result (also called the content recognition result), and is used to enhance the objective analysis capability of text / image features. The weight processing result can be the final score obtained by weighted calculation of the two recognition results. If the score exceeds the threshold, it is determined to be interference information.
[0064] Furthermore, in order to improve the weight processing effect and thus dynamically adapt to the characteristics of the web page, the above method further includes at least one of the following operations:
[0065] (1) Obtain user feedback information triggered by the web page, and adjust the first strategy weight and the second strategy weight according to the user feedback information. The user feedback information may include explicit feedback information and implicit feedback information. Explicit feedback information includes error correction instructions actively submitted by the user (such as clicking the "false alarm feedback" button), thereby directly adjusting the relevant strategy weights. Implicit feedback information can be indirect feedback derived from user behavior (such as revisiting the element after unblocking), thereby indirectly optimizing the weight configuration. For example, after the user marks "false blocking", the second strategy weight in this scenario is reduced, and the first strategy weight is increased.
[0066] (2) Monitor the page feature information of the web page and adjust the first strategy weight and the second strategy weight according to the page feature information. The page feature information is used to characterize the page type, such as e-commerce page, news page, social media page, etc., so that differentiated weight combinations can be preset for different types of pages. For example, for highly sensitive pages (such as financial payment pages), the second strategy weight can be increased and the first strategy weight can be reduced to strengthen security threat identification. For another example, the first strategy weight of the e-commerce page can be higher than the second strategy weight to focus on click behavior and product keywords; the first strategy weight of the news page can be lower than the second strategy weight to strengthen the semantic distinction between the main text and the advertisement.
[0067] In short, the dynamic weight allocation mechanism can improve the accuracy of interference information judgment, and can adjust the weight in real time based on user feedback and page features to adapt to different scenarios (such as e-commerce advertising and news promotion).
[0068] In an optional implementation, the first strategy may include: a user behavior identification strategy for identifying based on user-triggered operations of network users, and an element behavior identification strategy for identifying based on element-triggered operations of web page elements. Accordingly, based on the user-triggered operation corresponding to the web page element to be identified, the user operation behavior corresponding to the web page element to be identified is obtained, and the user behavior identification strategy is used to perform user behavior identification on the web page element to be identified, obtaining a user behavior identification result; based on the element-triggered operation corresponding to the web page element to be identified, the element operation behavior corresponding to the web page element to be identified is obtained, and the element behavior identification strategy is used to perform element behavior identification on the web page element to be identified, obtaining an element behavior identification result; and based on the user behavior identification result and the element behavior identification result, determining a first identification result of the web page element. Optionally, the user operation behavior can be characterized by operation frequency and / or event type, and the event type includes at least one of the following: mouse sliding, mouse clicking, and mouse hovering; the element operation behavior can include at least one of the following: launching an external link, launching an external video resource, and periodically calling a timer.
[0069] Among them, the user behavior identification strategy can be implemented by analyzing the rule set of element interference based on the user's active operation mode (such as clicking, sliding), aiming to identify based on the user's operation frequency and event type. Among them, the operation frequency is the number of times the user triggers the element per unit time (such as a click frequency >5 times / second is considered abnormal). The event type can be classified according to the interactive device and the type of action (such as a mouse hover for >2 seconds is considered deep attention, and a short click is considered a quick skip).
[0070] The element behavior identification strategy can be implemented based on a set of threat detection rules for element autonomous triggering behaviors (without direct user operation), and can be used to detect the following abnormal behaviors: (1) external resource loading: automatically jumping to a third-party link or loading cross-domain video resources; (2) timer call: periodically executing a script (such as refreshing advertising content every 10 seconds). Accordingly, by performing logical weighting or rule matching on the two behavior identification results, a comprehensive judgment conclusion is generated. For example, the specific weighting logic can be determined based on the behavior type: if the user frequently clicks (behavior dimension) and the element automatically jumps (element dimension) are met at the same time (both dimensions are met), it is judged as an inducement advertisement; if the user does not operate but the element frequently calls the timer (only meets the element dimension), it is judged as a potential malicious script. Among them, element operation behavior mainly refers to the dynamic operation or state change triggered by the DOM element in the web page at runtime, for example, the operation behavior triggered autonomously by the web page element without direct user operation.
[0071] This approach, through dual-dimensional behavior analysis, can avoid the high false positive rate and hidden interference that can be missed when relying solely on a single dimension, improving recognition effectiveness. Furthermore, user event types can also include touch gestures (such as zooming and long pressing) and voice commands, while element behaviors can also include WebSocket communication and local storage access. This application does not limit these specific details.
[0072] In an optional implementation, the second strategy includes at least one of the following: a hierarchical recognition strategy, an identification recognition strategy, and a visual recognition strategy. Accordingly, the second recognition result can be obtained by at least one of the following methods:
[0073] (1) Determine the nesting level of the web page element to be identified in the structure tree, identify the nesting level according to the hierarchical class identification strategy, and obtain the hierarchical class identification result. Among them, the hierarchical class identification strategy can be determined based on the nesting depth of the web page element in the structure tree (such as the DOM level). The nesting level refers to the path length from the root node to the current node of the element (such as the home page navigation bar is 3 levels, and the advertising container is 5 levels). Accordingly, the elements with a nesting level greater than the preset value, such as deep nesting (>4 levels) and no semantic tags, are determined as suspicious elements.
[0074] (2) Determine the identification information corresponding to the web page element to be identified, identify the identification information according to the identification information identification strategy, and obtain an identification information identification result; wherein the identification information includes: key information corresponding to the web page element to be identified and / or a hash value corresponding to the web page element to be identified. Therefore, it can be seen that the identification type identification strategy can quickly match known interference patterns through unique identification features (key information, hash fingerprint).
[0075] (3) Determine the visual information corresponding to the web page element to be identified, identify the visual information according to the visual recognition strategy, and obtain the visual information recognition result; wherein the visual information includes: the size information and / or orientation information of the web page element to be identified, the relative position information of the web page element to be identified relative to other web page elements, and the visual hierarchy of the web page element to be identified. The visual recognition strategy can identify the interference of the element based on the layout and visual performance (size, position, hierarchy) of the element. Among them, the visual hierarchy can be characterized by z-index, transparency, shadow effect, etc. For example, a hierarchy > 5 can be regarded as a floating element.
[0076] This method can greatly improve the accuracy and comprehensiveness of recognition through multi-dimensional content recognition technology (structural hierarchy, unique identification, and visual features).
[0077] In addition, the first strategy weight and the second strategy weight mentioned above may further include multiple sub-weights, corresponding to different refined identification strategies. For example, the first strategy weight further includes: user behavior strategy weight and element behavior strategy weight; the second strategy weight further includes: hierarchical strategy weight corresponding to the hierarchical identification strategy, identification strategy weight corresponding to the identification strategy, and visual strategy weight corresponding to the visual identification strategy. Moreover, the above-mentioned user behavior strategy weight, element behavior strategy weight, hierarchical strategy weight, identification strategy weight, and visual strategy weight can also be dynamically adjusted according to the user feedback information triggered for the web page and / or the page feature information of the monitored web page.
[0078] In an optional implementation, when the identification information is a hash value corresponding to the web page element to be identified, the hash value corresponding to the web page element to be identified can be matched with a preset interference hash library; if the matching result is yes, it is determined that the web page element to be identified contains interference information. Among them, the unique matching of hash values can improve the speed of advertisement recognition: only the hash library entries need to be compared, and the real-time dynamic update of the hash library is supported. Among them, the hash value is a unique string generated by a specific algorithm, which is used to characterize the core features of the web page element, and can include at least one of the following two generation methods: (1) Structural hash: Generate hash based on the element DOM hierarchy, tag sequence and attributes; (2) Visual hash: Generate perceptual hash based on the pixel distribution and color histogram after the element is rendered. The interference hash library is a database of pre-stored hash values of known interference elements.
[0079] In an optional implementation, the interference information may include advertising information. Accordingly, when shielding is performed on the web page element to be identified, the interference level of the web page element to be identified can be determined, and a shielding processing strategy corresponding to the interference level can be executed. Among them, the interference level includes at least: a first level and a second level. The shielding processing strategy corresponding to the first level includes: an interception strategy and / or a deletion strategy; the shielding processing strategy corresponding to the second level includes: a delayed loading strategy. For example, immediate interception is performed on high-risk advertisements (such as pop-ups, auto-playing videos), and delayed loading is used for low-interference advertisements (such as static banners). In addition, the interference level can be adjusted in real time based on advertising behavior patterns (such as frequency, user feedback) to reduce the false alarm rate.
[0080] To facilitate understanding, the following uses an example to describe the technical implementation details of the above embodiment. First, some concepts involved in this example are explained:
[0081] (1) Core Concepts and Terms
[0082] DOM (Document Object Model) tree: A tree-structured representation of web page content. Each HTML tag corresponds to a node, forming a parent-child hierarchical relationship. Content filtering and hash generation can be achieved by traversing and modifying the DOM tree.
[0083] Rule Engine: A system that makes automated decisions based on a predefined set of rules. It is used in CRHT (Compiled Regex Hash Table) for dynamic content filtering (such as ad blocking). For example, if a node contains the "data-ad" attribute, the subtree can be deleted. CRHT is a highly efficient content recognition technology that precompiles regular expressions and stores matching rules in hashed form. It is particularly suitable for ad blocking scenarios that require a fast response to dynamic content.
[0084] Context Awareness: Dynamically adjusts processing strategies based on a node's position in the DOM, visual weight, and interaction state. This can be used to prioritize high-value areas (such as product prices) and ignore low-value content (such as footer copyright information).
[0085] Hash Tree (Merkle Tree): A tree-like data structure where each node's hash value is calculated from the hashes of its child nodes, with the root hash representing the overall content fingerprint. This representation allows local changes to only affect the parent chain node, supporting efficient incremental updates.
[0086] Incremental Update: Recalculate the hash only for the changed DOM, rather than a full reconstruction. Specifically, you can use MutationObserver to monitor the change path and update the hash back along the parent chain.
[0087] (2) Technical component terms
[0088] MutationObserver: A browser-native API that can be used to monitor DOM tree changes (node additions, deletions, and modifications). Its function is to capture change events and trigger incremental hash updates of CRHT.
[0089] XPath (XML Path Language): A query language used to locate nodes in a DOM tree. Example:
[0090] / / div[@class="product-price"] selects all divs with class product-price node.
[0091] Regular Expression (Regex): A text pattern matching tool used to identify dynamic content (such as ad IDs and template variables). CRHT example: id="ad_\d+" matches ad container IDs like ad_123.
[0092] WAI-ARIA (Web Accessibility Initiative-ARIA): A technical specification for enhancing web accessibility that uses role and aria-* attributes to mark element semantics. For example, CRHT uses ARIA attributes like role="main" as a whitelist basis to exempt important areas from filtering.
[0093] BLAKE3: A high-speed cryptographic hash algorithm used to generate the master hash (strongly collision-resistant).
[0094] CRC32: Cyclic redundancy check algorithm, used for fast hash consistency comparison (high performance but low security).
[0095] (3) Performance indicator terminology
[0096] Time complexity: O(n) / O(log n): The computation time of traditional full hashing algorithms is proportional to the number of nodes. Therefore, O(n) is used to indicate that the computation time is linearly related to the total number of nodes (n), making it suitable for full traversal scenarios. In addition, CRHT's incremental hashing update time is only related to the tree height, significantly improving performance. Therefore, O(log n) is used to indicate that the computation time is proportional to the tree height (log n), making it suitable for incremental update scenarios.
[0097] Viewport Coverage: The ratio of the screen area occupied by the node in the visible area (calculated by getBoundingClientRect()), which is used to determine the weight of the node in the hash calculation (the higher the coverage, the greater the weight).
[0098] Interaction Density: The number of event listeners (such as click and input) bound to a node, used to mark nodes with high interaction density (such as buttons) as key content.
[0099] In related technologies, filtering of web page content is usually achieved through the following methods:
[0100] (1) Advertisement filtering based on rule matching:
[0101] Existing ad blocking plugins (such as AdBlock and uBlock Origin) rely on static rules, such as uniform resource locator (URL) blacklists, Cascading Style Sheets (CSS) selectors, and attribute matching. This approach suffers from the following drawbacks: rule updates rely on manual maintenance, making them incapable of adapting to advertisers' rapidly changing strategies. Furthermore, since filtering is based solely on tags and attributes, it cannot identify structured ad containers.
[0102] (2) Filtering method based on DOM update optimization of front-end framework:
[0103] For example, React uses Virtual DOM + Fiber for efficient incremental updates. Vue employs a diff algorithm for minimal DOM change detection. However, these approaches suffer from a drawback: they primarily serve components within the framework and offer limited support for incremental updates of native HTML structures. For example, when the DOM structure is large (such as complex tables or data visualizations), even Virtual DOM can introduce unnecessary updates, severely impacting performance.
[0104] However, with the rapid development of web technology, modern web pages are becoming increasingly complex, and the proportion of dynamic content continues to rise. Whether it's news websites, social media platforms, or e-commerce pages, content display is no longer limited to traditional static HTML; JavaScript-driven dynamic rendering is now widely adopted. At the same time, to increase advertising revenue, various websites are widely adopting technologies such as personalized advertising and dynamic content loading, posing a serious challenge to traditional content filtering methods.
[0105] It can be seen that traditional content filtering methods have at least the following limitations:
[0106] In the early days of the Web ecosystem, ad blocking and content filtering relied primarily on static rule matching. However, this approach has significant limitations when faced with modern, dynamic web page structures: (1) Static rules cannot adapt to dynamic content: Modern websites heavily utilize JavaScript for asynchronous loading (AJAX, WebSocket, Lazy Loading), and traditional HTML structure-based matching methods have difficulty capturing the final content presented on the page. (2) Advertisers constantly evade detection: Ad networks use methods such as dynamically generated class names, randomized IDs, and increased nesting depth to render fixed CSS rules ineffective. For example, ad container IDs may change randomly, making traditional rules difficult to apply universally. (3) False positives: Some news websites have recommended content that is similar in format to ad content. Overly simplistic blocking rules may result in the mistaken deletion of normal content, impacting user experience. (4) High performance overhead: Using too many regular matching rules may slow down page rendering, impacting user browsing experience.
[0107] To address the above challenges, some improvement solutions have been proposed: for example, an ad recognition solution based on artificial intelligence (AI): using deep learning to identify ad images and text. However, this method requires a large amount of training data and has high computational overhead, making it difficult to run efficiently on the client. Another example is a filtering solution based on behavioral analysis: some browser plug-ins judge ad content by monitoring user behavior (such as mouse hover time and click-through rate), but this method is ineffective for ads loaded for the first time (there is no interactive behavior for ads loaded for the first time) and there are privacy issues. It can be seen that although the improvement solution has improved the content filtering effect to a certain extent, it still has many problems such as high computational overhead, high privacy risks, and insufficient adaptability. Therefore, there is an urgent need for a low-cost, efficient, and dynamically adaptable web content filtering solution that can adapt to changes in web pages.
[0108] In order to solve the above problems, this example proposes a method for filtering web page content, which can at least achieve the following effects: (1) Efficiently identify dynamically loaded advertising content, solving the problem that traditional static rule-based methods cannot intercept content dynamically generated by JavaScript and require new mechanisms to capture the final rendered DOM structure. (2) Reduce accidental damage and improve recognition accuracy. Traditional methods rely solely on CSS selectors or blacklist matching, which can easily delete normal content by mistake. Therefore, more refined recognition strategies are needed, such as combining multi-dimensional information such as tags, attributes, and structures for judgment. (3) Improve filtering efficiency and reduce performance overhead. The traditional global DOM traversal method has high computational cost and requires incremental DOM analysis to avoid repeated scanning of the entire page.
[0109] To this end, this example proposes a multi-level dynamic content filtering mechanism based on a rule engine, which can accurately, efficiently and adaptively identify and intercept dynamic content. It is particularly suitable for scenarios such as ad blocking, spam shielding, and page optimization. It can intelligently filter and intercept specific content in web pages, such as advertisements, spam or other unnecessary dynamic elements, through the combination of multiple identification strategies. Traditional content filtering methods usually rely only on static rule matching, such as interception based on CSS selectors or blacklisted URLs. However, the above methods have limitations, especially in the case of dynamic content loading, advertiser avoidance strategies, and high false positive rates. The effectiveness of traditional methods will be greatly affected. Therefore, this example uses the Rule Chain method to perform a smarter and more refined analysis of the DOM structure of the web page, improve the accuracy of recognition, and reduce the accidental damage to normal content.
[0110] In this example, the first and second strategies mentioned above are further refined into multiple specific strategies. The following describes the strategy types involved in this example:
[0111] (1) Structural-Level Rules
[0112] The structural identification strategy is a specific implementation of the second strategy mentioned above. The structural identification strategy further includes tag-level rules, attribute-level rules, and structure-level rules:
[0113] Tag-Level Rules can be used for preliminary screening to quickly exclude known invalid tags. In web page content, some tags do not carry actual content themselves, but are used to load scripts, styles, and advertisements. These tags can be filtered out in the first step to reduce the cost of subsequent calculations. For example: <script>和<style>标签主要用于执行JavaScript代码和定义CSS样式,对页面的内容展示没有直接贡献,因此可以直接过滤掉,避免执行不必要的代码。<iframe>标签通常用于嵌入第三方内容,特别是广告商投放的跨站点广告。大部分广告网络(如Google Ads、Facebook Ads)都会使用<iframe>来加载广告内容,因此可以对不在白名单内的<iframe>进行屏蔽。另外,带有data-ad、advertisement、sponsored等属性的元素(即特定标识的标签),可以直接视为广告内容并移除。示例规则:移除<script>,<style>,<iframe>(非白名单);移除div、span等包含data-ad、advertisement关键字的元素。过滤流程如下:遍历整个DOM树,查找匹配的标签,直接删除非必要的脚本类标签(如<script>、<style>),对<iframe>进行白名单检查,将不属于允许列表中的iframe直接移除,并且,识别带有特定属性(如data-ad)的元素,并删除这些节点。该层级的过滤主要用于快速剔除无关内容,减少后续筛选所需的计算量,同时避免广告脚本执行,提高页面性能。
[0114] 属性级规则(Attribute-Level Rules)用于精准匹配、识别广告标识元素。由于标签级规则只能过滤掉显而易见的广告元素,而部分广告或不需要的内容可能隐藏在常规标签中(如、),因此,需要基于属性的规则进一步筛选。网页中的广告通常带有特定的class名称、ID或其他属性,例如,社交媒体上的推广内容,通常使用data-sponsored="true"、aria-label="Sponsored"等隐藏属性进行标记。属性级规则可以采用正则匹配+关键字列表,从而识别这些具有特殊命名模式的广告元素。例如:可以基于身份标识(Identity document,ID)规则过滤广告容器,可以基于Class规则识别广告横幅区域,基于数据属性屏蔽社交媒体上的推广内容。过滤流程如下:遍历DOM树的每个节点,检查其class、id、data等属性,如果class或id匹配黑名单规则,则删除该元素,检测隐藏广告标记(如data-sponsored、aria-label="Sponsored"),如果匹配,则移除该元素。另外,可以采用优先级机制:精确匹配(完整class或id匹配)>正则匹配>结构推断。该方式能够精准识别广告容器,减少误杀正常内容的可能性,适用于动态生成的广告,如社交媒体、新闻网站的推荐内容等。
[0115] 结构级规则可用于模式识别,推断隐藏广告:一些广告内容并不使用固定的标签或属性,而是通过特定的DOM结构进行展示。例如:深度嵌套的广告区域:某些广告可能隐藏在5层以上的div嵌套中,以逃避常规筛选。又如,有些网站采用单一容器模式,会在同一个div内放置多个广告组件(如多个iframe),或者,采用特定兄弟元素模式的某些广告可能位于两个固定的div之间(如article与related-posts之间)。因此,通过结构推断机制,能够分析DOM树的层级、节点特征,检测疑似广告区域。例如,可以实现嵌套深度检测(对应于上文提到的层级类识别策略):若div嵌套深度>5,并且包含iframe或img,则标记为广告容器。
[0116] (2)视觉级规则
[0117] 视觉级规则也叫视觉类识别策略,可用于根据网页中的视觉信息进行识别,具体实施时,可以借助网页结构进行视觉判断。例如,可以进行兄弟节点模式的识别:若某个div上下相邻的元素均为已知内容(如article),但自身不含内容,则判定为广告插入区域。
[0118] (3)内容级规则
[0119] 内容级规则用于实现内容模式匹配(可以对应于上文提到的标识类识别策略):分析innerText,若匹配sponsored by、advertisement等短语,则识别为广告。
[0120] (4)行为级规则
[0121] 行为级规则也可称作第一策略,用于根据用户操作行为和 / 或元素操作行为进行识别。
[0122] 由此可见,上述的多种规则属于上文提到的第二策略以及第一策略的具体实现形式。具体过滤流程如下:遍历DOM结构,计算每个div的嵌套深度,若深度超过阈值(如5层)且包含iframe / img,则视为广告。并且,分析兄弟节点的相对位置,判断是否属于广告插入区,最后,采用规则仲裁机制,结合标签级、属性级匹配结果,决定是否删除。上述方式可适用于隐藏式广告,如弹窗、悬浮广告等,结合模式推断,可识别逃避规则匹配的广告。
[0123] 在多层次过滤过程中,不同规则可能会对同一元素进行不同判定,因此,本示例采用优先级仲裁机制,以保证过滤的准确性。通过规则优先级仲裁(Rule Arbitration)机制,能够针对不同规则(结构级、行为级、视觉级、内容级)可能出现的冲突或不确定性进行动态调整,以提高检测准确性,减少误杀。当某个DOM元素符合多个检测规则,但这些规则的置信度或优先级不同,仲裁机制会按照权重计算,最终决策该元素是否属于广告,并采取相应的处理措施(屏蔽、标记、延迟加载等)。
[0124] 由此可见,可以针对不同的规则分别配置不同的权重,表1列出了几种规则的权重示意图:
[0125] 表1
[0126]
[0127] 例如,在初始情况下,结构级规则的优先级最高,因为DOM结构较稳定,误判风险较低。行为级和视觉级权重较中等,需要结合具体场景进行调整。纯内容匹配的规则权重最低,避免误杀非广告内容。规则仲裁机制可以采用加权置信度评分方式实现,计算方式如下:
[0128] Score_{element}=\sum_{i=1}^{n}(RuleWeight_i\times Confidence_i)
[0129] 其中,RuleWeight_i表示规则的权重(初始权重由系统设定,可根据环境调整);Confidence_i表示该规则的置信度(0-1之间),Score_{element}表示最终的置信得分,决定该元素是否为广告。例如,针对普通横幅广告,假设通过多种规则分别针对某个div检测到以下结果:
[0130] 结构级规则:嵌套6层(权重0.7),置信度0.9;
[0131] 视觉级规则:占据30%以上可视区域(权重0.5),置信度0.8;
[0132] 内容级规则:包含"Sponsored by”关键词(权重0.3),置信度0.6;
[0133] 计算得分:Score=(0.7\times 0.9)+(0.5\times 0.8)+(0.3\times 0.6)=0.63+0.4+0.18=1.21。
[0134] 预设的阈值如下:
[0135] Score≥1.0:判定为广告,直接屏蔽。
[0136] 0.6≤Score<1.0:可能是广告,延迟加载或标记。
[0137] Score<0.6:判定为非广告,忽略。
[0138] 若此元素最终得分1.21,超出1.0,则直接拦截。
[0139] 又如,为了避免误杀,若某div仅符合内容级规则,如包含"sponsored”关键词(权重0.3),置信度0.9。则计算得分:Score=0.3\times 0.9=0.27。由于低于0.6,不会误杀该元素,即不拦截。
[0140] 规则仲裁机制可以根据用户反馈、网站环境、历史数据动态调整权重,以提高适应能力。例如,规则仲裁机制可以根据用户反馈信息进行权重调整,以实现反馈自适应:若出现了误杀广告的情况(即检测到用户手动恢复的反馈行为):降低内容级规则权重(如0.3→0.2)。若出现了广告未被拦截的情况(即检测到用户手动屏蔽的反馈行为):提高结构级、视觉级权重(如0.7→0.8)。
[0141] 又如,规则仲裁机制可以根据网络页面的页面特征信息进行权重调整。比如,可以根据特定站点规则进行优化,如果某类广告在某站点常出现,则优先级自动上调。另外,还可以实现站点适应性:新闻网站的文本广告多,内容级规则权重可以上调(0.3→0.5);视频网站的视频插入广告多,行为级规则权重可以上调(0.5→0.7);社交媒体网站的悬浮广告较常见,视觉级规则权重可以上调(0.5→0.7)。相应的,根据最终仲裁得分,可以采取不同的过滤策略:若Score≥1.0,则直接屏蔽;若0.6≤Score<1.0,则延迟加载(如隐藏2s,若无用户交互则删除);若Score<0.6,则忽略、不拦截。
[0142] 相较于传统的基于黑名单或单一规则的广告拦截方式,本示例的多规则仲裁机制具有以下优势:通过动态权重调整,能够减少误差,可降低误杀率至2.8%以下;结合多层次检测,提升隐蔽广告识别能力,可提高拦截率,如拦截率达94%;自适应规则权重,可根据不同站点类型自动优化,能够动态适应新型广告;仅对疑似广告区域进行仲裁,不需要全量遍历,能够降低计算成本。总之,规则优先级仲裁机制通过多层次规则、置信度评分以及动态调整权重等方式,实现智能化广告拦截,避免误杀,提高拦截效率,同时可扩展到恶意脚本检测、网页内容审核等多个领域。
[0143] 另外,在本示例中,为了提升处理效率,在监测到网络页面发生改变的情况下,确定网络页面中发生改变的局部区域,通过增量更新方式更新网络页面的结构树中与局部区域相关联的至少一个子树。由此可见,本示例通过增量哈希树(Incremental Hash Tree,IHT)实现高效DOM变更处理,提高网页内容过滤的性能。其中,基于增量哈希树的动态内容检测方法的核心包括:将DOM树拆分为多个可复用的子树(Subtree Unit),每个子树独立维护哈希值,当页面内容发生变化时,仅重新计算受影响的子树,避免不必要的全量遍历,从而将时间复杂度从O(n)降低到O(log n),利用哈希值快速判定DOM结构变化,提高广告拦截和内容过滤的实时性。
[0144] 具体实施时,针对DOM树进行分层管理,在DOM结构中,网页内容是一个层次化的树形结构,如下所示:
[0145]
[0146]
[0147] 在本示例的增量哈希树方案中,将整个DOM树划分为多个子树单元,例如:#header、#content、#footer可作为一级子树;#content内的、、.ad可作为二级子树。每个子树都拥有独立的哈希值,如果某个子树发生变化,则仅重新计算该子树及其祖先节点的哈希,而不影响整个DOM结构。
[0148] 哈希计算策略如下:每个子树的哈希值是基于节点内容(文本、属性、子节点结构)计算的。子树的哈希值由其子节点哈希的合并值计算得出,即:Hash(Node)=Hash(Content)⊕Hash(Children)。
[0149] 另外,采用增量更新机制:如果某个叶子节点(如.ad)发生变化,则只需要更新该节点及其上层路径的哈希值,而不影响其他无关部分。例如,当.ad被动态替换成一个新广告,只需重新计算.ad及#content的哈希,而#header、#footer仍然保持原有哈希。
[0150] 变更检测机制如下:初次加载时,构建整个DOM树的哈希索引,并存储到内存中。当DOM发生变更(可通过MutationObserver监听)时,仅重新计算受影响的子树哈希。若哈希变化,则触发内容过滤规则进行重新检测(例如广告拦截)。通过对比前后哈希值,判断是否有新的动态广告加载。例如,如果#content.ad发生变化,系统仅重新计算#content及.ad,避免全局遍历整个DOM。如果#header没有变化,则不重新计算#header,提升计算效率。
[0151] 另外,增量哈希树不仅可用于检测DOM变化,还可结合内容过滤规则进行智能拦截:当某个子树的哈希值变化后,系统会检查其新内容是否匹配广告特征(例如class="ad")。若确认是新广告内容,则执行自动拦截,例如:直接移除该节点,或者,使用display:none隐藏,或者,向用户提供标记选项。
[0152] 综上可知,本示例提供了一种基于规则引擎的多层次动态内容过滤机制,结合增量哈希树,能够精准、高效、实时地检测和拦截动态网页中的广告、垃圾信息及其他不良内容。其中,通过标签级、属性级、结构级、视觉级、内容级等多层规则体系,构建了一种更加精细化、智能化的内容过滤方案(即多层次动态内容过滤方案),以适应现代网页的动态变化。并且,可以根据精确匹配>正则匹配>结构推断的优先级策略,实现优先级仲裁机制,提高拦截精准度,广告拦截率超过90%,同时减少误伤。而且,为了高效检测动态内容变更,引入了增量哈希树,实现了局部更新与增量计算,大幅降低性能开销。其中,将DOM树拆分为独立可复用的子树,每个子树维护独立哈希值,避免全局遍历(即子树单元化管理)。仅当某个子树发生变化时,才重新计算该子树及其父链哈希,降低时间复杂度。采用MutationObserver监听DOM变化,可通过哈希对比快速识别新增广告。即使广告商随机化class / id,改变内容加载方式,仍可精准检测变化内容。当检测到子树哈希变化后,系统会对比新内容的标签、属性、结构,并结合多层次规则决定是否拦截。另外,本示例还引入了视觉覆盖率分析,在增量更新时,仅对用户可见区域的DOM变化触发哈希计算。例如:一个隐藏的广告被替换则不更新,只有在一个广告区域进入可视区域,才触发更新,从而可减少超过60%的无效计算,提高整体过滤效率。而且,本示例采用层次化哈希结构,低级别进行细粒度跟踪DOM变更,中级别仅在局部子树发生重要变更时触发,高级别仅当全局内容发生大规模改动时才重新计算,从而可以减少全量计算的频率。
[0153] 上述方式显著提升了内容过滤的精准度(拦截率提升30%以上),精准识别并拦截网页中的广告、垃圾信息和恶意内容,即使这些内容采用动态加载、随机class / id、异步注入等方式规避传统规则,依然可以有效拦截。多层次过滤规则(标签级+属性级+结构级)结合优先级仲裁机制,能够精细化识别广告内容,避免误伤正常元素。增量哈希树变更检测机制,确保即使广告内容动态变化(例如滚动加载、懒加载、异步请求),仍可精准检测并拦截。采用结构级分析,可以识别深度嵌套的广告容器,而不仅仅依赖静态规则匹配,解决传统规则匹配方法容易被规避的问题。而且,能够大幅降低网页内容过滤的计算成本(CPU / 内存占用减少70%),可适用于大规模复杂网页,即使页面包含成千上万个DOM节点,也不会因为内容过滤导致浏览器卡顿。在DOM变更频繁的情况中,可以快速响应并优化DOM更新流程,提升页面流畅度。用户在浏览网页时,不会察觉到广告拦截或内容过滤带来的额外计算延迟,优化整体浏览体验。通过增量哈希树优化,确保在页面更新时仅对受影响的子树部分重新计算,避免全局回溯计算。通过非阻塞异步计算,确保过滤检测不会影响用户的正常交互,优化页面响应速度。该方式能够适应复杂网页结构,支持动态加载场景,无论内容是否懒加载、异步加载、滚动加载,都可以高效处理。传统内容过滤方法无法检测到异步加载的广告内容,而本方案可实时感知网页结构变化,确保动态内容也能被有效拦截。例如,MutationObserver结合增量哈希树,确保检测到懒加载、滚动加载、交互式加载的动态内容变更,实时更新过滤策略。子树级别的哈希追踪允许独立维护动态更新区域,不会因为部分内容变更而影响整个页面过滤逻辑。兼容浏览器原生API(如IntersectionObserver),确保即使内容尚未进入视口,仍可提前分析并标记可疑内容。通过子树哈希对比,即使广告内容采用动态JavaScript注入,也能在插入时立即发现,并触发拦截。采用基于机器学习的动态规则优化(可选扩展),能够自动学习广告商的新规避策略,持续优化检测逻辑。可扩展的规则引擎,可根据不同业务需求定义新的标签级、属性级、结构级规则,实现定制化内容过滤。因此,该方案不仅适用于广告拦截,还可以扩展至垃圾内容过滤、敏感信息检测、SEO优化、网页性能监控等多个领域,适用于浏览器插件、企业内容审核系统、前端优化工具。
[0154] 另外,在上述示例中,子树的拆分方式可以结合多种因素,以优化过滤效果和计算效率。具体来说,可以从以下几个方面进行优化:
[0155] (1)基于上下文感知的子树拆分方式:
[0156] 上下文感知(Context Awareness)可以帮助识别页面结构中的重要区域,在拆分子树时优先考虑这些区域。例如:基于语义分区,可以通过HTML语义标签(如<header>、<aside>、<section>)进行初步拆分。其中,HTML语义标签能够实现页面功能区域的划分,例如,<header>:通常包含页眉、导航栏或标题;<aside>通常用于指示侧边栏,可能包含广告或附加信息;<section>用于指示内容区块,通常对应正文段落。相应的,可以直接根据语义标签将DOM树拆分为多个子树,每个子树对应一个语义区块。例如,将
[0157] <header>和<aside>各自拆分为独立子树,确保导航和广告内容与正文分离。具体实施时,可以结合NLP技术分析文本内容,判断某些是否属于广告、导航、正文等不同类别,避免将无关内容合并到同一子树。其中,为了便于利用广告的显性特征(如类名、ID、结构模式)快速定位广告元素,可以基于广告特征进行预筛选,例如,可以通过模式匹配(如class="ad-banner")识别广告相关的DOM片段,并将其拆分成单独的子树。又如,可以结合历史数据(如增量哈希树)识别曾经被屏蔽的元素结构,并优先拆分这些元素结构,以便精确匹配和拦截。哈希树用于将DOM子树的结构(标签、类名、层级等)计算为唯一哈希值,并存储到历史数据库中,若某子树曾被标记为广告,则其哈希值会被记录,因而可以针对该子树对应的元素结构进行拦截。增量更新是指:当页面更新时,仅对新生成的DOM节点计算哈希,并与历史库比对,能够快速识别重复广告结构。
[0158] (2)基于视觉覆盖率的子树拆分方式:
[0159] 视觉覆盖率(Visual Coverage)用于表征页面上的某个区域对用户的影响程度,因此可以作为拆分子树的依据。具体实施时,可以基于可视区域的优先级进行拆分。其中,高覆盖率区域(Above the Fold)通常指屏幕首次加载时可见的部分,这些区域的广告影响最大,因此应拆分为较小的子树,以便更精准地检测和拦截。例如,可以将页面首次加载时无需滚动即可看到的区域(如首屏内容)作为高覆盖率区域,用户的注意力通常集中在该部分区域。相应的,可以将首屏区域的DOM拆分为更小的子树。例如,首屏中的每个广告位(如横幅、推荐位)独立成树,便于逐个检测和拦截。低覆盖率区域(Below the Fold)通常指滚动后方可看到的内容(如文章底部、评论区),该部分内容可以合并成较大的子树,以减少计算开销。例如,可以将多个低优先级区域(如底部的多个推广链接)合并为同一子树,减少子树数量以降低计算开销。
[0160] 另外,还可以基于页面元素的相对布局进行子树拆分。例如,可以计算DOM元素的面积比例(如元素的width*height占整个页面的百分比),如果某个元素的占比较大,则可能是背景广告或遮罩广告,可以优先拆分。
[0161] 另外,还可以基于层级分析结果进行拆分。例如,可以结合z-index值,判断是否为浮动广告(如悬浮窗、弹窗),将z-index值较高的元素(可能为浮动广告或弹窗)单独拆分,以便快速匹配并移除。
[0162] (3)基于用户交互行为的子树拆分方式:
[0163] 用户交互行为(如鼠标移动、点击、焦点变化)可以作为动态拆分子树的依据,以优化信息过滤效果。例如,可以基于鼠标轨迹进行优化:统计用户鼠标在不同区域的停留时间,若某个子树范围内的鼠标交互较少,则可能是广告区域,可拆分成独立子树并标记为低优先级内容。另外,还可以结合热图分析(Heatmap),对用户关注度高的区域进行精细拆分,以提高检测精度。还可以基于滚动行为进行优化,例如,对于页面中随滚动加载的内容(如无限滚动页面),可以动态调整子树拆分方式:在初始阶段使用较大粒度的拆分,而在滚动后使用更细粒度的拆分。
[0164] (4)基于增量哈希树的子树拆分方式:
[0165] 该方式可以基于子树的哈希计算结果进行拆分。例如,对于每个子树,计算其DOM结构的哈希值,并存储在增量哈希树中,以便后续快速匹配和识别相似内容。例如,对每个子树的DOM结构进行特征提取,生成唯一哈希值,提取的特征可以包括以下中的至少一个:(1)结构特征:标签层级、类名、ID、子节点数量;(2)内容特征:文本关键词(如"广告”"推广”)、图片URL模式(如ad.jpg);(3)布局特征:面积覆盖率(width*height)、位置(视口坐标)、z-index值;(4)行为特征:事件监听(如onclick触发弹窗)。若某个子树的哈希值与已知的广告哈希匹配,可直接屏蔽该子树,以提高过滤效率。另外,还可以动态调整子树拆分策略。例如,通过增量哈希树跟踪不同网站的广告模式,若某类网站的广告结构变化较快,则可以使用更小粒度的子树拆分,以便更快适应变化。具体实施时,可以通过历史哈希库存储已知的广告子树的哈希值,在增量更新的流程中,当页面加载时,仅对新出现的DOM节点计算哈希,若计算的哈希未命中历史哈希库,可以标记为潜在新广告,并触发进一步分析(如NLP语义验证),并在确定为新广告后,将其哈希值加入库中,并关联拦截规则。其中,通过动态调整子树拆分策略,能够实现拆分粒度的自适应。结合上下文感知,可以基于语义结构、广告特征进行合理拆分,提高识别精度。例如,可以优先拆分语义标签(<aside>,<footer>)内的子树,因其更可能包含广告。另外,对无语义的,可以通过NLP分析文本意图(如是否含促销信息)决定是否拆分。结合视觉覆盖率,可以优先拆分高影响区域,减少计算量。例如,对高影响区域,如首屏的子树立即计算哈希并匹配,对低影响区域,如非首屏内容则可以延迟处理,或合并为粗粒度子树。结合交互状态,可以动态调整拆分方式,提高适应性。例如,当检测到用户滚动事件时,实时计算新进入视口的子树哈希。并且,监听点击事件,若触发广告行为(如跳转外链),则回溯关联子树并更新哈希库。举例而言,当用户点击"领取优惠券”等广告按钮后,系统标记对应的子树为广告,并记录哈希值。结合增量哈希树,可以优化哈希计算和子树匹配效率,提高过滤效果。
[0166] 另外,可选的,在上述示例中,上下文感知可以用于优化前端表格组件的数据展示和交互体验。具体而言,系统会结合位置、视觉权重、交互状态等多个维度的信息,对数据进行动态调整,以提高信息获取的效率和用户体验。以下分别展开说明,并阐述其与多层次过滤及增量哈希树的技术关联:
[0167] (1)位置(Position)
[0168] 在表格组件中,用户通常会关注当前视口范围内的数据。系统通过监听滚动事件,动态检测用户视口的范围,并基于可视区域的行列信息进行数据的优先加载和渲染。对于固定列、冻结行等特殊区域,系统赋予更高的优先级,确保这些部分始终处于最优显示状态。若用户在搜索框输入内容,系统可根据视口范围内的数据匹配度进行实时排序,将与搜索内容匹配度高的行优先呈现,而不破坏原有表格结构。与多层次过滤的关联:位置感知可作为第一层过滤条件,即仅针对当前可见区域的数据执行计算,减少不必要的查询开销。在大数据量场景下,结合增量哈希树索引技术,可以快速筛选出当前视口范围内的数据,避免全表扫描,提高检索速度。
[0169] (2)视觉权重(Visual Weight)
[0170] 依据用户的鼠标悬停、点击、浏览历史等行为,计算各列的视觉权重,并动态调整列宽、对齐方式、甚至隐藏低权重列。例如,在财务报表中,用户可能更关注交易金额列,系统可通过分析用户的交互轨迹,自动提升该列的优先级,使其默认靠左或加粗显示。视觉权重还可结合设备分辨率,在小屏设备上自动隐藏次要信息,仅保留高权重列。与多层次过滤的关联:视觉权重可以作为第二层过滤条件,在数据展示时自动调整列的优先级,从而优化用户阅读体验。结合增量哈希树,可以对交互频率较高的字段生成索引,使其在查询时具有更高的匹配优先级,加快数据检索。
[0171] (3)交互状态(Interaction State)
[0172] 在用户进行排序、筛选、编辑等操作时,系统会记录当前的交互状态,并结合历史操作模式,预测用户的后续操作。例如,若用户频繁筛选某个时间范围,系统可自动在后续筛选框中默认选中相应的时间区间,减少重复操作。在多用户协作模式下,若某个用户正在编辑表格中的某个单元格,系统可对该单元格上锁,并在其他用户尝试编辑时给予适当的提示。与多层次过滤的关联:交互状态可作为第三层过滤条件,即基于用户的实际操作习惯,动态调整数据查询和渲染策略。结合增量哈希树,可以针对用户高频操作的列构建索引,加速筛选和排序,提高响应速度。
[0173] 总之,上下文感知技术可以通过位置、视觉权重、交互状态等维度优化表格数据的展示和交互体验,并与多层次过滤和增量哈希树形成协同优化机制:多层次过滤方式,负责逐级筛选数据,减少无关数据的计算量;增量哈希树方式,负责对关键字段进行快速索引,提高查询性能;上下文感知方式,负责动态调整表格的展示逻辑,使数据呈现更加智能化。
[0174] 另外,考虑到首次加载的广告相较于非首次广告具有以下特殊性:(1)缺乏用户行为数据:行为分析方法(如基于鼠标悬停时间、点击率的过滤)依赖于用户与页面的交互数据。然而,首次加载时,用户尚未产生任何交互,因此无法利用这些行为数据进行过滤。(2)通常与页面结构强绑定:许多广告是在页面初始渲染时由服务器端直接注入,而非后续动态加载。例如,横幅广告、插页式广告通常在页面首次加载时就已经存在。这些广告可能嵌入在HTML结构中,并与页面其他元素共享CSS规则,使其难以单纯依靠DOM结构或样式特征检测。(3)更易绕过基于动态分析的检测:许多广告商利用首次加载的特权,在用户未产生交互之前就展示广告,从而规避某些行为分析型的过滤策略。例如,一些网站在页面加载时直接请求广告资源,而不是通过JavaScript动态插入,以避免被脚本拦截。(4)可能受到反广告拦截技术的保护:部分网站会针对广告拦截技术进行检测,若发现广告被屏蔽,可能会触发替代方案(如请求用户关闭广告拦截器或直接拒绝加载内容)。这些防御机制通常在首次加载时执行,因此仅依靠行为分析难以绕过。
[0175] 因此,针对首次加载的广告和非首次加载的广告,应该采用不同的过滤策略:
[0176] (1)首次加载广告的处理策略
[0177] 基于网页结构和资源分析:通过DOM结构分析(如检测iframe、广告常见的CSS类名、特定的广告标识符)来识别广告组件。
[0178] 结合网络请求分析:检查是否加载了广告相关的第三方域名资源(如ads.doubleclick.net)。
[0179] 利用增量哈希树记录已知广告资源的哈希值,以便快速匹配已识别的广告内容。
[0180] 基于上下文感知的内容过滤:通过文本和图片特征检测,结合机器学习模型判断某些关键字(如"Sponsored”、"Ad”)或图片特征(如占位符图像)是否属于广告内容。结合视觉权重分析,如果某个区域的尺寸、位置、样式符合广告特征(如固定在顶部、覆盖页面、半透明背景),则优先屏蔽。
[0181] 降低对页面加载性能的影响:由于首次加载的广告通常与页面结构深度绑定,因此直接移除可能影响正常内容的渲染。采用占位隐藏策略(如display:none)或延迟加载替换(如用透明div替换广告内容),避免破坏页面布局。
[0182] (2)非首次加载广告的处理策略
[0183] 基于行为分析的动态过滤:追踪用户鼠标、滚动、点击等行为,识别可能的广告区域,并根据用户的交互习惯进行过滤。例如,如果某个区域的点击率极低、鼠标悬停时间短,且与广告特征匹配,则可以在后续访问中自动屏蔽。
[0184] 基于异步请求拦截:许多广告是通过AJAX请求或WebSocket加载的,非首次广告通常出现在页面滚动或用户交互后。监听fetch / XMLHttpRequest请求,分析广告网络请求模式,并在检测到广告资源时进行拦截或替换。
[0185] 用户个性化过滤:结合增量哈希树维护用户的广告拦截偏好,例如:如果用户曾手动屏蔽某类广告(如视频广告),系统可以优先拦截类似内容;通过AI记录用户对某些页面元素的交互模式,逐步优化过滤策略。
[0186] 首次加载的广告由于缺乏用户行为数据、深度绑定页面结构、可能绕过行为分析,需要依赖静态结构分析、网络请求分析和上下文感知过滤来处理。而非首次广告通常是动态加载的,可以基于用户行为分析、异步请求拦截和个性化策略进行过滤。
[0187] 另外,第二策略以及第一策略除上文提到的内容之外,还可以增加以下更细粒度的规则,以提高隐藏广告的识别能力:(1)异常尺寸模式(属于第二策略):广告通常具有固定的尺寸比例,例如300×250(矩形)、728×90(横幅)等,而正常的内容区域通常尺寸不固定。识别出极端长宽比的div,尤其是:极宽但高度较低(横幅广告,如width>700px&&height<100px);极高但宽度较窄(侧边栏广告,如height>500px&&width<200px);接近正方形的广告块(如width≈height,用于社交广告或推荐内容)。该方式能够过滤掉标准尺寸的广告横幅和侧边栏广告。(2)异常交互模式(属于第一策略):正常的内容区域用户可自由选择是否交互,但广告区域往往会强制用户交互(如自动播放、强制点击)。具体实施时,可以识别以下异常交互行为:自动播放视频(带有autoplay属性的<video>);鼠标悬停即触发事件(检测onmouseover事件);点击即跳转至外部网站(带有onclick事件,并指向外部站点);重复的setTimeout / setInterval调用(用于定期刷新广告)。该方式能够识别自动播放视频广告、强制跳转广告等恶意广告行为。(3)透明 / 隐藏广告:一些广告通过CSS降低透明度或移出可视区域来隐藏,从而逃避检测:opacity:0或visibility:hidden(完全透明但仍然占据空间)。display:none(不占用空间,但仍然存在于DOM)。position:absolute+left:-9999px(移出可视区域)。最小尺寸(width<5px&&height<5px,用于像素级广告追踪)。通过检测能够识别隐藏式广告,防止其规避过滤机制。
[0188] 可以理解,本公开提及的上述各个方法实施例,在不违背原理逻辑的情况下,均可以彼此相互结合形成结合后的实施例,限于篇幅,本公开不再赘述。本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。
[0189] 此外,本公开还提供了数据处理装置、电子设备、计算机可读存储介质,上述均可用来实现本公开提供的任一种数据处理方法,相应技术方案和描述和参见方法部分的相应记载,不再赘述。
[0190] 图3为本公开实施例提供的一种数据处理装置的框图。
[0191] 参照图3,本公开实施例提供了一种数据处理装置,该数据处理装置包括:
[0192] 筛选模块31,适于响应于针对网络页面触发的用户交互事件,从所述网络页面的结构树包含的多个子树中,筛选与所述用户交互事件的事件属性信息匹配的子树;其中,所述结构树用于表征所述网络页面中的多个网页子区域,所述子树用于表征所述网页子区域中的网页元素;
[0193] 确定模块32,适于根据与所述用户交互事件的事件属性信息匹配的子树,确定所述网络页面中待识别的网页元素;
[0194] 识别模块33,适于获取所述待识别的网页元素对应的触发操作,通过第一策略对所述触发操作进行识别,得到第一识别结果;通过第二策略对所述待识别的网页元素进行内容识别,得到第二识别结果;
[0195] 处理模块34,适于在根据所述第一识别结果以及所述第二识别结果确定所述待识别的网页元素包含干扰信息的情况下,对所述待识别的网页元素执行屏蔽处理。
[0196] 在一种可选的实现方式中,所述筛选模块具体用于:
[0197] 在所述用户交互事件的事件类型与预设调整类型匹配的情况下,从所述网络页面的结构树中确定所述用户交互事件对应的子树;
[0198] 针对所述用户交互事件对应的子树的子树划分方式进行调整,得到调整后的结构树;
[0199] 从调整后的结构树包含的多个子树中,筛选与所述用户交互事件的事件属性信息匹配的子树。
[0200] 在一种可选的实现方式中,所述预设调整类型包括:第一调整类型以及第二调整类型;
[0201] 所述筛选模块具体用于:
[0202] 若所述用户交互事件的事件类型与第一调整类型匹配,针对所述用户交互事件对应的子树的子树划分方式进行合并式调整,以使所述用户交互事件对应的子树的子树数量减少;
[0203] 若所述用户交互事件的事件类型与第二调整类型匹配,针对所述用户交互事件对应的子树的子树划分方式进行拆分式调整,以使所述用户交互事件对应的子树的子树数量增加。
[0204] 在一种可选的实现方式中,所述第一调整类型包括:滑动速度超过预设速度阈值的滑动事件类型、和 / 或交互频次小于第一频次阈值的交互事件类型;
[0205] 所述第二调整类型包括:悬停时长大于预设悬停阈值的鼠标悬停事件类型、和 / 或交互频次大于第二频次阈值的交互事件类型。
[0206] 在一种可选的实现方式中,所述确定模块还用于:
[0207] 在监测到所述网络页面发生改变的情况下,确定所述网络页面中发生改变的局部区域,通过增量更新方式更新所述网络页面的结构树中与所述局部区域相关联的至少一个子树;
[0208] 并且,所述网络页面中待识别的网页元素进一步根据预设时段内进行更新的至少一个子树确定。
[0209] 在一种可选的实现方式中,所述处理模块具体用于:根据所述第一策略的第一策略权重以及所述第二策略的第二策略权重,对所述第一识别结果以及所述第二识别结果进行权重处理,根据权重处理结果确定所述待识别的网页元素是否包含干扰信息;
[0210] 并且,所述装置还包括:
[0211] 权重调节模块,用于获取针对所述网络页面触发的用户反馈信息,根据所述用户反馈信息调整所述第一策略权重以及所述第二策略权重;和 / 或,监测所述网络页面的页面特征信息,根据所述页面特征信息调整所述第一策略权重以及所述第二策略权重。
[0212] 在一种可选的实现方式中,所述第一策略包括:用户第一策略以及元素第一策略;所述识别模块具体用于:
[0213] 根据与所述待识别的网页元素相对应的用户触发操作,获取与所述待识别的网页元素相对应的用户操作行为,通过所述用户第一策略对所述待识别的网页元素进行用户行为识别,得到用户第一识别结果;
[0214] 根据与所述待识别的网页元素相对应的元素触发操作,获取与所述待识别的网页元素相对应的元素操作行为,通过所述元素第一策略对所述待识别的网页元素进行元素行为识别,得到元素第一识别结果;
[0215] 根据所述用户第一识别结果以及所述元素第一识别结果,确定所述网页元素的第一识别结果;
[0216] 其中,所述用户操作行为通过操作频次和 / 或事件类型表征,且所述事件类型包括以下中的至少一个:鼠标滑动、鼠标点击、鼠标悬停;所述元素操作行为包括以下中的至少一个:启动外部链接、启动外部视频资源、周期性调用定时器。
[0217] 在一种可选的实现方式中,所述第二策略包括以下中的至少一个:层级类识别策略、标识类识别策略、以及视觉类识别策略;所述通过第二策略对所述待识别的网页元素进行内容识别,得到第二识别结果包括以下中的至少一种:
[0218] 确定所述待识别的网页元素在所述结构树中的嵌套层级,根据所述层级类识别策略对所述嵌套层级进行识别,得到层级类识别结果;
[0219] 确定所述待识别的网页元素对应的标识信息,根据所述标识信息识别策略对所述标识信息进行识别,得到标识信息识别结果;其中,所述标识信息包括:所述待识别的网页元素对应的关键信息和 / 或所述待识别的网页元素对应的哈希值;
[0220] 确定所述待识别的网页元素对应的视觉信息,根据所述视觉类识别策略对所述视觉信息进行识别,得到视觉信息识别结果;其中,所述视觉信息包括:待识别的网页元素的尺寸信息和 / 或方位信息、所述待识别的网页元素相对于其他网页元素的相对位置信息、所述待识别的网页元素的视觉层级。
[0221] 在一种可选的实现方式中,在所述标识信息为所述待识别的网页元素对应的哈希值的情况下,所述识别模块具体用于:
[0222] 将所述待识别的网页元素对应的哈希值与预设的干扰哈希库进行匹配;若匹配结果为是,确定所述待识别的网页元素包含干扰信息。
[0223] 在一种可选的实现方式中,所述干扰信息包括广告信息,所述处理模块具体用于:
[0224] 确定所述待识别的网页元素的干扰等级,执行与所述干扰等级相对应的屏蔽处理策略;
[0225] 其中,所述干扰等级至少包括:第一等级以及第二等级,所述第一等级对应的屏蔽处理策略包括:拦截策略和 / 或删除策略;所述第二等级对应的屏蔽处理策略包括:延迟加载策略。
[0226] 上述数据处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
[0227] 图4为本公开实施例提供的一种电子设备的框图。
[0228] 参照图4,本公开实施例提供了一种电子设备,该电子设备包括:至少一个处理器501;至少一个存储器502,以及一个或多个I / O接口503,连接在处理器501与存储器502之间;其中,存储器502存储有可被至少一个处理器501执行的一个或多个计算机程序,一个或多个计算机程序被至少一个处理器501执行,以使至少一个处理器501能够执行上述的数据处理方法。
[0229] 上述电子设备中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
[0230] 本公开实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序在被处理器执行时实现上述的数据处理方法。计算机可读存储介质可以是易失性或非易失性计算机可读存储介质。
[0231] 本公开实施例还提供了一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备的处理器中运行时,所述电子设备中的处理器执行上述数据处理方法。
[0232] 本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统、装置中的功能模块 / 单元可以被实施为软件、固件、硬件及其适当的组合。在硬件实施方式中,在以上描述中提及的功能模块 / 单元之间的划分不一定对应于物理组件的划分;例如,一个物理组件可以具有多个功能,或者一个功能或步骤可以由若干物理组件合作执行。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读存储介质上,计算机可读存储介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。
[0233] 如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读程序指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM)、静态随机存取存储器(SRAM)、闪存或其他存储器技术、便携式压缩盘只读存储器(CD-ROM)、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读程序指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。
[0234] 这里所描述的计算机可读程序指令可以从计算机可读存储介质下载到各个计算 / 处理设备,或者通过网络、例如因特网、局域网、广域网和 / 或无线网下载到外部计算机或外部存储设备。网络可以包括铜传输电缆、光纤传输、无线传输、路由器、防火墙、交换机、网关计算机和 / 或边缘服务器。每个计算 / 处理设备中的网络适配卡或者网络接口从网络接收计算机可读程序指令,并转发该计算机可读程序指令,以供存储在各个计算 / 处理设备中的计算机可读存储介质中。
[0235] 用于执行本公开操作的计算机程序指令可以是汇编指令、指令集架构(ISA)指令、机器指令、机器相关指令、微代码、固件指令、状态设置数据、或者以一种或多种编程语言的任意组合编写的源代码或目标代码,所述编程语言包括面向对象的编程语言—诸如Smalltalk、C++等,以及常规的过程式编程语言—诸如"C”语言或类似的编程语言。计算机可读程序指令可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络—包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。在一些实施例中,通过利用计算机可读程序指令的状态信息来个性化定制电子电路,例如可编程逻辑电路、现场可编程门阵列(FPGA)或可编程逻辑阵列(PLA),该电子电路可以执行计算机可读程序指令,从而实现本公开的各个方面。
[0236] 这里所描述的计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software DevelopmentKit,SDK)等等。
[0237] 这里参照根据本公开实施例的方法、装置(系统)和计算机程序产品的流程图和 / 或框图描述了本公开的各个方面。应当理解,流程图和 / 或框图的每个方框以及流程图和 / 或框图中各方框的组合,都可以由计算机可读程序指令实现。
[0238] 这些计算机可读程序指令可以提供给通用计算机、专用计算机或其它可编程数据处理装置的处理器,从而生产出一种机器,使得这些指令在通过计算机或其它可编程数据处理装置的处理器执行时,产生了实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和 / 或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作的各个方面的指令。
[0239] 也可以把计算机可读程序指令加载到计算机、其它可编程数据处理装置、或其它设备上,使得在计算机、其它可编程数据处理装置或其它设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其它可编程数据处理装置、或其它设备上执行的指令实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作。
[0240] 附图中的流程图和框图显示了根据本公开的多个实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,所述模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和 / 或流程图中的每个方框、以及框图和 / 或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
[0241] 本文已经公开了示例实施例,并且虽然采用了具体术语,但它们仅用于并仅应当被解释为一般说明性含义,并且不用于限制的目的。在一些实例中,对本领域技术人员显而易见的是,除非另外明确指出,否则可单独使用与特定实施例相结合描述的特征、特性和 / 或元素,或可与其他实施例相结合描述的特征、特性和 / 或元件组合使用。因此,本领域技术人员将理解,在不脱离由所附的权利要求阐明的本公开的范围的情况下,可进行各种形式和细节上的改变。< / script>
Claims
1. A data processing method, characterized in that: include: In response to a user interaction event triggered on a web page, a subtree matching event attribute information of the user interaction event is selected from a plurality of subtrees included in a structure tree of the web page; wherein the structure tree is used to represent a plurality of web page sub-regions in the web page, and the subtrees are used to represent web page elements in the web page sub-regions; Determining the web page element to be identified in the web page according to the matched subtree; Obtaining a trigger operation corresponding to the webpage element to be identified, identifying the trigger operation using a first strategy, and obtaining a first identification result; Performing content recognition on the webpage element to be recognized using a second strategy to obtain a second recognition result; When it is determined according to the first recognition result and the second recognition result that the webpage element to be recognized contains interference information, shielding processing is performed on the webpage element to be recognized.
2. The method according to claim 1, characterized in that The step of screening a subtree matching the event attribute information of the user interaction event from the multiple subtrees included in the structure tree of the network page includes: In a case where the event type of the user interaction event matches a preset adjustment type, determining a subtree corresponding to the user interaction event from the structure tree of the network page; Adjusting the subtree partitioning method of the subtree corresponding to the user interaction event to obtain an adjusted structure tree; From the multiple subtrees included in the adjusted structure tree, a subtree matching the event attribute information of the user interaction event is screened.
3. The method according to claim 2, characterized in that The preset adjustment types include: a first adjustment type and a second adjustment type; The adjusting of the subtree division method of the subtree corresponding to the user interaction event includes: If the event type of the user interaction event matches the first adjustment type, performing a merging adjustment on the subtree partitioning mode of the subtree corresponding to the user interaction event, so as to reduce the number of subtrees of the subtree corresponding to the user interaction event; If the event type of the user interaction event matches the second adjustment type, a splitting adjustment is performed on the subtree partitioning mode of the subtree corresponding to the user interaction event, so that the number of subtrees of the subtree corresponding to the user interaction event increases.
4. The method according to claim 3, characterized in that The first adjustment type includes: a sliding event type in which the sliding speed exceeds a preset speed threshold, and / or an interaction event type in which the interaction frequency is less than a first frequency threshold; The second adjustment type includes: a mouse hover event type with a hover duration greater than a preset hover threshold, and / or an interaction event type with an interaction frequency greater than a second frequency threshold.
5. The method according to any one of claims 1 to 4, characterized in that: The network page is a dynamic web page, and the method further includes: In the case where a change is detected in the web page, determining a changed area in the web page, and updating at least one subtree associated with the changed area in a structure tree of the web page by incremental updating; Furthermore, the webpage element to be identified in the webpage is determined according to at least one subtree updated within a preset period of time.
6. The method according to any one of claims 1 to 4, characterized in that: The determining, based on the first recognition result and the second recognition result, that the to-be-recognized webpage element contains interference information includes: performing weight processing on the first recognition result and the second recognition result according to a first policy weight of the first policy and a second policy weight of the second policy, and determining whether the webpage element to be recognized contains interference information according to the weight processing result; The method further comprises: Obtain user feedback information triggered by the web page, and adjust the first policy weight and the second policy weight according to the user feedback information; and / or monitor page feature information of the web page, and adjust the first policy weight and the second policy weight according to the page feature information.
7. The method according to claim 6, characterized in that The first strategy includes: a user behavior identification strategy for identifying based on a user triggering operation of a network user, and an element behavior identification strategy for identifying based on an element triggering operation of a web page element; obtaining the triggering operation corresponding to the web page element to be identified, identifying the triggering operation using the first strategy, and obtaining a first identification result, including: According to the user trigger operation corresponding to the web page element to be identified, the user operation behavior corresponding to the web page element to be identified is obtained, and the user behavior identification strategy is used to perform user behavior identification on the web page element to be identified to obtain a user behavior identification result; Acquiring an element operation behavior corresponding to the web page element to be identified according to an element trigger operation corresponding to the web page element to be identified, performing element behavior identification on the web page element to be identified using the element behavior identification strategy, and obtaining an element behavior identification result; Determining a first recognition result of the webpage element according to the user behavior recognition result and the element behavior recognition result; Among them, the user operation behavior is characterized by operation frequency and / or event type, and the event type includes at least one of the following: mouse sliding, mouse clicking, mouse hovering; the element operation behavior includes at least one of the following: starting an external link, starting an external video resource, and periodically calling a timer.
8. The method according to claim 6, characterized in that The second strategy includes at least one of the following: a hierarchical recognition strategy, an identification recognition strategy, and a visual recognition strategy; and the second recognition result obtained by performing content recognition on the webpage element to be recognized using the second strategy includes at least one of the following: Determining the nesting level of the webpage element to be identified in the structure tree, identifying the nesting level according to the hierarchy class identification strategy, and obtaining a hierarchy class identification result; Determining identification information corresponding to the webpage element to be identified, identifying the identification information according to the identification information identification strategy, and obtaining an identification information identification result; wherein the identification information includes: key information corresponding to the webpage element to be identified and / or a hash value corresponding to the webpage element to be identified; Determine the visual information corresponding to the web page element to be identified, identify the visual information according to the visual class identification strategy, and obtain a visual information identification result; wherein, the visual information includes: size information and / or orientation information of the web page element to be identified, relative position information of the web page element to be identified with respect to other web page elements, and visual hierarchy of the web page element to be identified.
9. The method according to claim 8, characterized in that In a case where the identification information is a hash value corresponding to the webpage element to be identified, identifying the identification information according to the identification information identification strategy to obtain an identification information identification result includes: The hash value corresponding to the webpage element to be identified is matched with a preset interference hash library; if the matching result is yes, it is determined that the webpage element to be identified contains interference information.
10. The method according to any one of claims 1 to 4, characterized in that: The shielding process for the webpage element to be identified includes: Determining an interference level of the webpage element to be identified, and executing a shielding processing strategy corresponding to the interference level; The interference level includes at least a first level and a second level. The shielding processing strategy corresponding to the first level includes an interception strategy and / or a deletion strategy. The shielding processing strategy corresponding to the second level includes a delayed loading strategy.
11. A data processing device, characterized in that: include: a screening module adapted to, in response to a user interaction event triggered on a web page, screen a subtree matching event attribute information of the user interaction event from a plurality of subtrees included in a structure tree of the web page; wherein the structure tree is used to represent a plurality of web page sub-regions in the web page, and the subtrees are used to represent web page elements in the web page sub-regions; a determination module, adapted to determine a webpage element to be identified in the webpage according to the matched subtree; an identification module adapted to obtain a trigger operation corresponding to the web page element to be identified, identify the trigger operation using a first strategy to obtain a first identification result, and perform content identification on the web page element to be identified using a second strategy to obtain a second identification result; The processing module is adapted to perform shielding processing on the web page element to be identified when it is determined that the web page element to be identified contains interference information according to the first identification result and the second identification result.
12. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor. The one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the data processing method according to any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the data processing method according to any one of claims 1 to 10.
14. A computer program product, characterized in that A computer-readable storage medium comprising a computer-readable code or carrying a computer-readable code, wherein when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the data processing method according to any one of claims 1 to 10.
Citation Information
Cited By
Non-intrusive webpage adaptive processing method and system based on instantaneous environment situation
CN122087214A
A webpage update identification method, device, medium and equipment
CN122470798A