A method, apparatus, and storage medium for webpage context compression
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2026-08-14
AI Technical Summary
[0003]本申请实施例提供了一种网页上下文压缩方法、装置及存储介质,以解决如何提高Web上下文压缩效率的问题
[0017] The technical solution of this application embodiment obtains the type of operation currently performed by the user by filtering all semantic elements in the initial webpage context, and determines the target-irrelevant operation tag corresponding to the operation type. Then, the element information corresponding to the element with the tag type of target-irrelevant operation tag is compressed to generate a compressed webpage context. This application effectively reduces the amount of data in the target webpage context, thereby reducing memory usage and computing resource consumption, and shortening the time for data transmission, parsing, and processing in subsequent automated operations.
Smart Images

Figure CN120632242B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of web page processing technology, and in particular to a web page context compression method, apparatus and storage medium. Background Technology
[0002] In the field of web automation, efficient parsing of the web context is often involved, using it as input to models for understanding and manipulation. The size of the web context directly impacts the efficiency and accuracy of subsequent tasks. Here, the web context primarily refers to the Document Object Model (DOM) tree. Furthermore, the DOM tree contains numerous semantically unimportant noisy elements, offering room for compression. Current technologies typically do not perform compression when acquiring the web context; they either directly use the complete DOM tree or perform only simple compression, such as simply removing irrelevant attributes and styles. Therefore, current technologies generally suffer from low compression efficiency when processing web contexts. Summary of the Invention
[0003] This application provides a web page context compression method, apparatus, and storage medium to address the problem of how to improve the efficiency of web context compression.
[0004] In a first aspect, embodiments of this application provide a webpage context compression method, the method comprising:
[0005] For the target webpage, the elements in the initial webpage context of the target webpage are traversed to obtain all semantic elements contained in the initial webpage context;
[0006] Obtain the current operation type corresponding to the operation performed by the user on the target webpage;
[0007] Obtain the target-independent operation label corresponding to the current operation type;
[0008] The element information corresponding to the element whose tag type is the target-irrelevant operation tag among all the speech elements is compressed to obtain the compressed webpage context.
[0009] Secondly, embodiments of this application also provide a webpage context compression device, the device comprising:
[0010] The traversal module is used to traverse the elements in the initial webpage context of the target webpage to obtain all semantic elements contained in the initial webpage context.
[0011] The first acquisition module is used to acquire the current operation type corresponding to the operation performed by the user on the target webpage;
[0012] The second acquisition module is used to acquire the target-independent operation label corresponding to the current operation type;
[0013] The first compression module is used to compress the element information corresponding to the elements whose tag type is the target-irrelevant operation tag among all the speech elements to obtain the compressed webpage context.
[0014] Thirdly, embodiments of this application also provide an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the above-described web page context compression method.
[0015] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described webpage context compression method.
[0016] The embodiments of this application include at least the following technical effects:
[0017] The technical solution of this application embodiment obtains the type of operation currently performed by the user by filtering all semantic elements in the initial webpage context, and determines the target-irrelevant operation tag corresponding to the operation type. Then, the element information corresponding to the element with the tag type of target-irrelevant operation tag is compressed to generate a compressed webpage context. This application effectively reduces the amount of data in the target webpage context, thereby reducing memory usage and computing resource consumption, and shortening the time for data transmission, parsing, and processing in subsequent automated operations. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the webpage context compression method provided in an embodiment of this application;
[0019] Figure 2 This is a schematic diagram of the webpage context compression device provided in the embodiments of this application;
[0020] Figure 3 A block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0023] In the various embodiments of this application, it should be understood that the sequence number of each process described below does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0024] In the field of web automation, efficient parsing of the web context is often involved, using it as input to models for understanding and manipulation. The size of the web context directly affects the efficiency and accuracy of subsequent work. Here, the web context mainly refers to the Document Object Model (DOM) tree. Furthermore, the DOM tree contains many semantically unimportant noisy elements, allowing for compression.
[0025] During their research, the inventors discovered that existing technologies typically do not perform compression when obtaining the Web context; they either directly use the complete DOM tree as the Web context or only perform simple compression, such as simply removing irrelevant attributes and styles from the DOM tree. Therefore, current technologies generally suffer from low compression efficiency when processing Web contexts.
[0026] Based on this, in order to solve the problem of how to improve the efficiency of web context compression, this application provides a web page context compression method, apparatus and storage medium, which can effectively reduce the amount of data in the target web page context, thereby reducing memory occupation and computing resource consumption, and shortening the time for data transmission, parsing and processing in subsequent automated operations.
[0027] like Figure 1 As shown in the figure, this application provides a webpage context compression method, which includes:
[0028] Step 101: For the target webpage, traverse the elements in the initial webpage context of the target webpage to obtain all semantic elements contained in the initial webpage context.
[0029] In the embodiments of this application, the target webpage can be a variety of webpages with different functions and uses, such as e-commerce webpages, social media webpages, news information webpages, corporate websites, etc. This application does not specifically limit the category of the target webpage.
[0030] Web pages are composed of numerous elements. In the field of web page automation, not all elements are crucial to the automation operation; therefore, some irrelevant elements, such as decorative and redundant elements, need to be excluded. This application, when determining the web page context of the target web page, needs to compress the initial web page context of the target web page to obtain a compressed web page context. This initial web page context includes the complete information environment of the target web page, which can be presented in the form of a Document Object Model (DOM) tree.
[0031] After obtaining the initial webpage context, the elements in the initial webpage context are traversed. For example, using DOM traversal methods such as those in JavaScript, starting from the root node of the initial webpage context (i.e., the DOM tree) of the target webpage, a depth-first traversal or breadth-first traversal algorithm is used to access each element in the DOM tree. During the traversal, semantic elements are identified and filtered based on features such as the tag type of the elements. For example, the tag type of each element can be determined based on a predefined set of semantic element tags. If the element tag belongs to the set of semantic element tags, the element is kept; otherwise, the element is excluded. After the above traversal and filtering, all semantic elements contained in the initial webpage context can be obtained.
[0032] Step 102: Obtain the current operation type corresponding to the operation performed by the user on the target webpage.
[0033] Considering that different user operations have different focuses in web page automation scenarios, this application also needs to obtain the current operation type corresponding to the user's operation on the target web page. Specifically, this can be achieved through an event listener mechanism, such as using JavaScript's `addEventListener` method to listen for events like mouse clicks and keyboard input. When an event is triggered, the current operation type is determined based on the event type and related operation logic. For example, if it is detected that a user clicked a button on the page, and that button is associated with a data query function, then the current operation type is determined to be a "data query operation".
[0034] Step 103: Obtain the target-independent operation label corresponding to the current operation type.
[0035] In this embodiment, for each operation type, corresponding irrelevant operation tags can be pre-defined. These tags correspond to elements that have no substantial impact on the operation result in that scenario. For example, in a data query operation, elements on the page used for layout and only serving a style separation function have little relevance to the data query operation and can be designated as elements corresponding to the target irrelevant operation tags. Furthermore, based on the analysis of various automated operation requirements and webpage element functions, compressible elements can be accurately located.
[0036] Step 104: Compress the element information corresponding to the elements whose tag type is the target-irrelevant operation tag among all the speech elements to obtain the compressed webpage context.
[0037] After identifying the target-irrelevant operation tags, elements with these tags are selected from all audio elements, and their corresponding element information is compressed. Specifically, this compression can be attribute compression and text content compression. Attribute compression involves iterating through the attribute list of the selected elements, identifying attributes related to page style display but having no substantial effect on automated operations, such as background color and font size, and removing these attributes from the elements. Text content compression involves checking the text content of the selected elements; if there is a large amount of redundant or irrelevant text, such as advertising slogans or decorative explanatory text, it is deleted or simplified, retaining only the key information. By compressing the element information corresponding to elements with target-irrelevant operation tags from all audio elements, the amount of data occupied by elements can be reduced without changing the basic function and semantics of the elements, thus achieving effective compression of the webpage context.
[0038] In this embodiment, by filtering all semantic elements in the initial webpage context, the type of operation currently being performed by the user is obtained, and the target-independent operation tag corresponding to that operation type is determined. Then, the element information corresponding to the element with the tag type of target-independent operation tag is compressed to generate a compressed webpage context. This application effectively reduces the amount of data in the target webpage context, thereby reducing memory usage and computational resource consumption, and shortening the time for data transmission, parsing, and processing in subsequent automated operations.
[0039] The following describes how to traverse the initial webpage context to obtain all semantic elements in step 101. In an optional embodiment of this application, traversing the elements in the initial webpage context to obtain all semantic elements contained in the initial webpage context includes:
[0040] Obtain the operation type and attribute information corresponding to each element in the initial webpage context;
[0041] The initial webpage context includes elements whose operation type is operable, elements whose operation type is non-operable and contain text, elements whose attribute information includes interactive attributes, elements whose attribute information is visible attributes, and elements whose attribute information includes multimedia attributes, thus obtaining all semantic elements.
[0042] Within a webpage context, webpage elements are stored in a tree structure, with each element being a node in the tree. Element information includes at least tags, attributes, and text content. Traversing the webpage context (i.e., the DOM tree) yields the operation type and attribute information for each element. The operation type can be based on the webpage's interaction logic; events bound to the element (such as clicks or input events) determine its operation type, which can be categorized as operable or non-operable. Attribute information can be directly extracted from the element's attribute set. This information collectively constitutes the element's characteristic description, providing a data foundation for filtering. Attribute information can include the element's identifier, link address, display style, and interactive characteristics. Then, based on the operation type and attribute information corresponding to each element, preliminary filtering is performed to obtain all semantic elements contained in the initial webpage context.
[0043] Specifically, during the initial screening of elements, multiple dimensions can be used to retain elements closely related to the core semantics of the webpage and user interactions, while eliminating redundant or irrelevant elements. Each screening dimension will be described below.
[0044] 1. Filter out elements with an actionable type. Actionable elements are those that can directly interact with the user, such as buttons, links, input boxes, and drop-down menus. As the core carriers of web page interaction, actionable elements are of great significance for automated operations and user experience analysis. For example, after obtaining the action types of all elements, filter out elements with action types such as "click," "input," "select," and "submit" that can trigger specific functions.
[0045] Second, filter out elements containing text that are classified as "non-operable". While non-operable elements lack direct interactive functionality, their text content may carry important information, such as page titles, paragraph text, and explanatory text. For example, title tags and paragraph tags on a webpage do not generate interactive behavior themselves, but convey the webpage's theme or introduce relevant knowledge through their text content. By checking whether elements contain text nodes, these types of elements can be filtered out, ensuring that the core content information of the webpage is not overlooked.
[0046] Third, filter elements with interactive attributes. Elements with interactive attributes are those that possess interactive features or can provide additional interactive information. These elements include at least those bound to a click event and those with an onclick attribute. Filtering out elements with interactive attributes helps in a more comprehensive understanding of the interactive logic and functionality of web page elements.
[0047] Fourth, filter elements whose attribute information is visible, that is, exclude elements whose display property is none, because these elements are not visible on the page, cannot be interacted with by users, and have no practical significance for automated operations on the webpage. Visible elements are those that are actually presented to the user on the page. This can be determined by checking the element's display, visibility, and other CSS properties. If the display property value is not none and the visibility property value is not hidden, then the element is visible. By filtering visible elements, you can focus on the page content that the user can actually perceive and interact with.
[0048] 5. Filtering elements with multimedia attributes. Multimedia attribute elements include elements related to multimedia resources such as images, audio, and video. Filtering elements with multimedia attributes helps in the management and analysis of web page multimedia resources.
[0049] By filtering through the above multiple dimensions, all semantic elements can be obtained.
[0050] The above-described implementation scheme of this application obtains the operation type and attribute information corresponding to each element in the initial webpage context, and performs multi-dimensional filtering on the elements included in the initial webpage context based on the operation type and attribute information to obtain all semantic elements. It can accurately extract semantic elements closely related to the core functions of the webpage, user interaction and information transmission from the complex initial webpage context, reduce the amount of data in the initial webpage context, remove a large number of irrelevant elements, provide accurate target objects for subsequent webpage analysis and automated operations, and avoid interference from irrelevant elements.
[0051] The following describes how to obtain the target-independent label in step 103. In an optional embodiment of this application, obtaining the target-independent label corresponding to the current operation type includes:
[0052] Obtain the correspondence between operation types and irrelevant operation labels;
[0053] Based on the correspondence, a target-irrelevant operation label corresponding to the current operation type is determined.
[0054] Different webpage operation types have different focuses, and the roles of webpage elements also vary across these operations. Through analysis and summarization of numerous webpage operation scenarios, we identified which elements in each operation type have a weaker relevance to the operation's purpose, defining these elements as irrelevant operation tags. We then associated operation types with their corresponding irrelevant operation tags, forming an operation type-irrelevant operation tag mapping table—the correspondence between operation types and irrelevant operation tags—providing a basis for subsequent filtering.
[0055] Once the current operation type performed by the user on the target webpage is obtained, a search is performed in the established operation type-irrelevant operation tag mapping table to find the set of irrelevant operation tags that match the current operation type. The elements corresponding to these tags can be considered irrelevant elements in the current operation scenario, thus completing the determination of the target irrelevant operation tags. Operation types include, but are not limited to, click, input, positioning, scrolling, and double-click. If the current operation type is click, elements with the tags "select", "a", and "input" can be excluded. If the operation type is input, only elements with the tag "input" are retained.
[0056] The above-described implementation scheme of this application, by identifying the user's current operation type and excluding elements corresponding to irrelevant operation tags, achieves dynamic compression of the webpage context based on user instructions, reduces the loading, parsing and processing of irrelevant elements, and greatly shortens the execution time of webpage analysis and automated operations.
[0057] Considering that the richer the webpage context, the larger the amount of webpage context data, in order to further compress the webpage context, in an optional embodiment of this application, after obtaining the compressed webpage context, the method further includes:
[0058] Obtain the number of attributes and style types corresponding to each element in the compressed webpage context;
[0059] Based on the number of attributes and style types corresponding to each element, feature parameters are determined to characterize the richness of webpage scene features corresponding to the compressed webpage context.
[0060] Determine whether the feature parameter is greater than a preset threshold;
[0061] When the feature parameter is greater than the preset threshold, the attribute information and style information corresponding to each element in the compressed webpage context are compressed into word embedding information through a word embedding model.
[0062] The richness of a webpage scene can be characterized by the number of attributes and style types of elements within the webpage context. This embodiment of the application traverses and compresses each element in the webpage context, counting the number of attributes and style types for each element. The number of attributes reflects the data complexity carried by the element, including information such as the element's function and data relationships; the number of style types reflects the diversity of the element's visual presentation, such as different colors, layouts, and animation effects. By statistically analyzing these two dimensions, a quantitative index reflecting the richness of webpage scene features can be constructed. Specifically, based on the number of attributes and style types corresponding to each element, feature parameters are determined to characterize the richness of webpage scene features corresponding to the compressed webpage context. These feature parameters can be obtained by weighted summation or other mathematical operations on the number of attributes and style types of each element. The weighting coefficients can be adjusted according to the actual scenario; for example, in scenarios emphasizing interaction, the weight of the number of attributes can be appropriately increased, and in scenarios emphasizing display effects, the weight of the number of style types can be appropriately increased.
[0063] In this embodiment, a feature parameter threshold, or preset threshold, can be set based on business needs and historical data. After obtaining the feature parameter, it is compared with the preset threshold. When the feature parameter is greater than the preset threshold, it indicates that the target webpage has rich element semantic attributes and styles. The preset threshold can be flexibly adjusted according to different business scenarios, avoiding the blind application of uniform processing to all scenarios and achieving optimized resource allocation. For example, in mobile webpage processing, the threshold can be lowered to trigger word embedding optimization earlier, adapting to the limited computing resources of mobile devices; in complex desktop application scenarios, the threshold can be increased to focus on pages that truly need optimization.
[0064] Word embedding models can map textual information to a low-dimensional vector space while preserving semantic relationships. When the feature parameters representing the richness of webpage scene features exceed a preset threshold, it indicates that the contextual data is large and structurally complex, and direct processing will increase computational cost and noise interference. In this case, attribute and style information can be compressed into word embedding information, i.e., word embedding vectors, using word embedding models.
[0065] The above-described implementation scheme of this application, when the target webpage has rich semantic attributes and styles, compresses attribute information and style information into word embedding information through a word embedding model, thereby further compressing the webpage context while preserving key semantics and improving subsequent processing efficiency.
[0066] The following describes how word embedding information is obtained in the previous embodiment. In an optional embodiment of this application, the attribute information and style information corresponding to each element in the compressed webpage context are compressed into word embedding information using a word embedding model, including:
[0067] Feature extraction is performed on the attribute and style information corresponding to each element in the compressed webpage context to obtain the feature information corresponding to the element;
[0068] For each element in the compressed webpage context, the feature information corresponding to the element is mapped to a word embedding vector of a preset length through the word embedding model to obtain the word embedding information corresponding to the element.
[0069] Considering that the element attribute and style information in the compressed webpage context usually contains a large amount of text and data, we first extract features from the attribute and style information corresponding to each element in the compressed webpage context to obtain the feature information corresponding to each element. Through feature extraction, we can reduce data redundancy and improve the efficiency and accuracy of subsequent processing. For example, unnecessary symbols, spaces, and special characters can be removed.
[0070] Word embedding models are techniques for converting text data into vector representations. Common word embedding models include Word2Vec, GloVe, and BERT. By inputting the feature information of each element into the word embedding model, the model converts it into a word embedding vector of a preset length. This allows the originally discrete text information to be represented in a continuous vector form while preserving the semantic information of the text. For example, the attribute and style information of an element might originally contain dozens or even hundreds of characters; after being converted into a 300-dimensional word embedding vector, the data volume is significantly reduced.
[0071] The above-described implementation scheme of this application significantly reduces data storage space and transmission costs by converting the attribute and style information of elements into fixed-length word embedding vectors. Simultaneously, the word embedding vectors preserve the semantic relationships of the text information, allowing for a better understanding of the meaning and function of elements in subsequent processing and analysis.
[0072] In an optional embodiment of this application, after obtaining the compressed webpage context, the method further includes:
[0073] For each element in the compressed webpage context, delete the attributes in the attribute information corresponding to the element that are irrelevant to the current operation type.
[0074] Element-based attribute information often contains a large amount of content irrelevant to the current specific operation, increasing data complexity and processing burden, and offering no substantial help in executing or understanding the current operation. This application's embodiments, after obtaining the compressed webpage context, can check the attribute information of each element in the compressed webpage context according to the predefined correspondence between operation types and irrelevant attributes, identify attributes irrelevant to the current operation type, and delete them. This effectively reduces data volume and redundancy. For example, for a "search operation," attributes related to the display style of search results can be defined as irrelevant attributes.
[0075] The above-described implementation scheme of this application, by deleting attributes that are irrelevant to the current operation type, can make the core information related to the current operation more prominent, and can further reduce the amount of data, thereby compressing the webpage context.
[0076] In an optional embodiment of this application, after obtaining the compressed webpage context, the method further includes:
[0077] Obtain the path information corresponding to each element in the compressed webpage context;
[0078] For each element in the compressed webpage context, the parent path information is extracted from the path information corresponding to the element, and the path information corresponding to the element is replaced with the parent path information.
[0079] After obtaining the compressed webpage context, for each element, DOM-related methods can be used to retrieve its path information. In the Document Object Model (DOM) of a webpage, an element's path information is used to uniquely identify the element's position in the DOM tree. Path information can represent the hierarchical structure of elements on the page. For complex webpages, accurate path information is crucial for understanding the relationships between elements and performing related operations. Then, for each element, the parent path information is extracted from its path information. The parent path information is a part of the element's path information and represents the element's higher-level position information in the DOM tree.
[0080] In this embodiment of the application, the original path information of each element is replaced with the extracted parent path information.
[0081] The above-described implementation scheme of this application simplifies the complexity of the path by retaining the parent path information, thereby eliminating the need to process excessive details when locating and manipulating web page elements.
[0082] In an optional embodiment of this application, after obtaining the compressed webpage context, the method further includes:
[0083] Obtain the location information corresponding to each element in the compressed webpage context;
[0084] For each element in the compressed webpage context, the positioning information is added to the element information corresponding to that element.
[0085] An element's location information provides a unique identifier for it. This information can include identifiers (IDs), categories, and more. In complex page structures, different elements may have the same tag name and text content; location information allows for accurate differentiation. For example, in a page containing multiple buttons, the target button can be accurately located using its ID.
[0086] Using location information allows you to quickly find target elements in the DOM tree. Compared to traversing the entire DOM tree to find elements, location information allows you to directly locate the target element, reducing search time.
[0087] In this embodiment of the application, after obtaining the compression context, the positioning information corresponding to each element in the compressed webpage context is also obtained and added to the element information corresponding to the element.
[0088] The above-described implementation scheme of this application, by adding positioning information to the element information, can directly and quickly locate the element to be searched based on the added positioning information, significantly improving the efficiency and accuracy of element positioning.
[0089] The webpage context compression method provided by the embodiments of this application has been described above. The webpage context compression device provided by the embodiments of this application will be described below with reference to the accompanying drawings.
[0090] like Figure 2 As shown, this embodiment of the invention also provides a webpage context compression device, the device comprising:
[0091] The traversal module 201 is used to traverse the elements in the initial webpage context of the target webpage to obtain all semantic elements contained in the initial webpage context.
[0092] The first acquisition module 202 is used to acquire the current operation type corresponding to the operation performed by the user on the target webpage;
[0093] The second acquisition module 203 is used to acquire the target-independent operation label corresponding to the current operation type;
[0094] The first compression module 204 is used to compress the element information corresponding to the element whose tag type is the target-irrelevant operation tag among all the speech elements to obtain the compressed webpage context.
[0095] Optionally, the traversal module includes:
[0096] The first acquisition submodule is used to acquire the operation type and attribute information corresponding to each element in the initial webpage context;
[0097] The filtering submodule is used to filter elements from the elements included in the initial webpage context that have the operation type of operable, elements that contain text and have the operation type of non-operable, elements whose attribute information includes interactive attributes, elements whose attribute information has visible attributes, and elements whose attribute information includes multimedia attributes, to obtain all semantic elements.
[0098] Optionally, the second acquisition module includes:
[0099] The second acquisition submodule is used to obtain the correspondence between operation types and irrelevant operation tags;
[0100] The determination submodule is used to determine the target-independent operation label corresponding to the current operation type based on the correspondence.
[0101] Optionally, after obtaining the compressed webpage context, the apparatus further includes:
[0102] The third acquisition module is used to acquire the number of attributes and the number of style types corresponding to each element in the compressed webpage context;
[0103] The determination module is used to determine the feature parameters that characterize the richness of webpage scene features corresponding to the compressed webpage context, based on the number of attributes and style types corresponding to each element.
[0104] The judgment module is used to determine whether the feature parameter is greater than a preset threshold.
[0105] The second compression module is used to compress the attribute information and style information corresponding to each element in the compressed webpage context into word embedding information by means of a word embedding model when the feature parameter is greater than the preset threshold.
[0106] Optionally, the second compression module includes:
[0107] The extraction submodule is used to extract features from the attribute information and style information corresponding to each element in the compressed webpage context to obtain the feature information corresponding to the element.
[0108] The mapping submodule is used to map the feature information corresponding to each element in the compressed webpage context to a word embedding vector of a preset length through the word embedding model, thereby obtaining the word embedding information corresponding to the element.
[0109] Optionally, after obtaining the compressed webpage context, the apparatus further includes:
[0110] The attribute processing module is used to delete attributes that are irrelevant to the current operation type from the attribute information corresponding to each element in the compressed webpage context.
[0111] Optionally, after obtaining the compressed webpage context, the apparatus further includes:
[0112] The fourth acquisition module is used to acquire the path information corresponding to each element in the compressed webpage context;
[0113] The path processing module is used to extract the parent path information from the path information corresponding to each element in the compressed webpage context, and replace the path information corresponding to the element with the parent path information.
[0114] Optionally, after obtaining the compressed webpage context, the apparatus further includes:
[0115] The fourth acquisition module is used to acquire the positioning information corresponding to each element in the context of the compressed webpage;
[0116] The location information processing module is used to add the location information to the element information corresponding to each element in the compressed webpage context.
[0117] The webpage context compression device provided in this application obtains the user's current operation type by filtering all semantic elements in the initial webpage context and determines the target-independent operation tag corresponding to that operation type. Then, it compresses the element information corresponding to the element whose tag type is a target-independent operation tag, thereby generating a compressed webpage context. This application effectively reduces the amount of data in the target webpage context, thereby reducing memory usage and computational resource consumption, and shortening the time for data transmission, parsing, and processing in subsequent automated operations.
[0118] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0119] This application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described web page context compression method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0120] For example, Figure 3 A schematic diagram of the physical structure of an electronic device is shown. (For example...) Figure 3As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340. The processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330. The processor 310 is used to perform the following steps: for a target webpage, traverse the elements in the initial webpage context of the target webpage to obtain all semantic elements contained in the initial webpage context; obtain the current operation type corresponding to the operation performed by the user on the target webpage; obtain the target-independent operation tag corresponding to the current operation type; compress the element information corresponding to the element with the tag type of the target-independent operation tag among all the speech elements to obtain a compressed webpage context. The processor 310 can also execute other schemes in the embodiments of this application, which will not be further described here.
[0121] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a web-based device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0122] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described webpage context compression method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here. The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0123] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0124] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or web page device, etc.) to execute the methods described in the various embodiments of this application.
[0125] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0126] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0127] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0128] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0129] The units described as separate components may or may not be physically separate. The components displayed as units may or may not be physical units; that is, they may be located in one place or distributed across multiple web page units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0130] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0131] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a web-based device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, external hard drives, ROM, RAM, magnetic disks, or optical disks.
[0132] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A webpage context compression method, characterized in that, The method includes: For the target webpage, the elements in the initial webpage context of the target webpage are traversed to obtain all semantic elements contained in the initial webpage context; Obtain the current operation type corresponding to the operation performed by the user on the target webpage; Obtain the target-irrelevant operation label corresponding to the current operation type. The target-irrelevant operation label is the label of the element with weak correlation to the operation purpose under each operation type. The element information corresponding to the elements whose tag type is the target-irrelevant operation tag among all the semantic elements is compressed to obtain the compressed webpage context; The step of traversing the elements in the initial webpage context to obtain all semantic elements contained in the initial webpage context includes: Obtain the operation type and attribute information corresponding to each element in the initial webpage context; The initial webpage context includes elements whose operation type is operable, elements whose operation type is non-operable and contain text, elements whose attribute information includes interactive attributes, elements whose attribute information is visible attributes, and elements whose attribute information includes multimedia attributes, thus obtaining all semantic elements.
2. The webpage context compression method according to claim 1, characterized in that, Obtaining the target-irrelevant label corresponding to the current operation type includes: Obtain the correspondence between operation types and irrelevant operation labels; Based on the correspondence, a target-irrelevant operation label corresponding to the current operation type is determined.
3. The webpage context compression method according to claim 1, characterized in that, After obtaining the compressed webpage context, the method further includes: Obtain the number of attributes and style types corresponding to each element in the compressed webpage context; Based on the number of attributes and style types corresponding to each element, feature parameters are determined to characterize the richness of webpage scene features corresponding to the compressed webpage context. Determine whether the feature parameter is greater than a preset threshold; When the feature parameter is greater than the preset threshold, the attribute information and style information corresponding to each element in the compressed webpage context are compressed into word embedding information through a word embedding model.
4. The webpage context compression method according to claim 3, characterized in that, The attribute and style information corresponding to each element in the compressed webpage context is compressed into word embedding information using a word embedding model, including: Feature extraction is performed on the attribute and style information corresponding to each element in the compressed webpage context to obtain the feature information corresponding to the element; For each element in the compressed webpage context, the feature information corresponding to the element is mapped to a word embedding vector of a preset length through the word embedding model to obtain the word embedding information corresponding to the element.
5. The webpage context compression method according to claim 1, characterized in that, After obtaining the compressed webpage context, the method further includes: For each element in the compressed webpage context, delete the attributes in the attribute information corresponding to the element that are irrelevant to the current operation type.
6. The webpage context compression method according to claim 1, characterized in that, After obtaining the compressed webpage context, the method further includes: Obtain the path information corresponding to each element in the compressed webpage context; For each element in the compressed webpage context, the parent path information is extracted from the path information corresponding to the element, and the path information corresponding to the element is replaced with the parent path information.
7. The webpage context compression method according to claim 1, characterized in that, After obtaining the compressed webpage context, the method further includes: Obtain the positioning information corresponding to each element in the compressed webpage context; For each element in the compressed webpage context, the positioning information is added to the element information corresponding to that element.
8. A webpage context compression device, characterized in that, include: The traversal module is used to traverse the elements in the initial webpage context of the target webpage to obtain all semantic elements contained in the initial webpage context. The first acquisition module is used to acquire the current operation type corresponding to the operation performed by the user on the target webpage; The second acquisition module is used to acquire the target-irrelevant operation label corresponding to the current operation type. The target-irrelevant operation label is the label of the element with weak correlation to the operation purpose under each operation type. The first compression module is used to compress the element information corresponding to the elements whose tag type is the target-irrelevant operation tag among all the semantic elements to obtain the compressed webpage context; The traversal module includes: The first acquisition submodule is used to acquire the operation type and attribute information corresponding to each element in the initial webpage context; The filtering submodule is used to filter elements from the elements included in the initial webpage context that have the operation type of operable, elements that contain text and have the operation type of non-operable, elements whose attribute information includes interactive attributes, elements whose attribute information has visible attributes, and elements whose attribute information includes multimedia attributes, to obtain all semantic elements.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the web page context compression method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
A control method and a control device for shielding web page elements based on user behavior
CN109408747A
Method, apparatus, and computer-readable medium for transforming a hierarchical document object model to filter non-rendered elements
US20210342531A1