Path determination method, device, equipment and storage medium
By obtaining the attributes and label information of page elements and combining it with a recursive upward search method to generate the shortest path, the problem of automation and intelligence in determining the path of page elements is solved, and the adaptability and effectiveness of the path are improved.
Patent Information
- Application Number
- CN202111302677.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-04
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2041-11-04
AI Technical Summary
In the prior art, the path determination method of page elements is difficult to realize automation and intelligence, and the path is easily affected by changes in the page code document structure, resulting in path failure.
By obtaining the attribute information and tag information of the target page elements and the reference page elements, combined with the recursive upward search method, the path information of the page elements is generated, and the shortest path is determined by reverse regression to adapt to changes in the page code document.
It realizes the automation and intelligent determination of page element paths, improves the effectiveness of paths, and enables them to adapt to structural changes in page code documents.
Smart Images

Figure CN116070042B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a path determination method, apparatus, device, and storage medium. Background Art
[0002] Computer display pages such as web pages (hereinafter referred to as pages) are generated by rendering a page code document. All page elements displayed on the page have corresponding codes in the page code document. The code position of the page element can be located through the unique path of the page element in the page code document, so that the page element can be accessed and operated. However, how to determine the path of the page element is a problem to be solved. Summary of the Invention
[0003] The embodiments of the present application provide a path determination method, apparatus, device, and storage medium, which can realize the automation and intelligence of determining the path of page elements and effectively improve the path validity of page elements.
[0004] In one aspect, an embodiment of the present application provides a path determination method, the method comprising:
[0005] Acquire first attribute information of a target page element and second attribute information of a reference page element, wherein the target page element and the reference page element are included in a page code document, and the reference page element and the target page element have the same parent page element;
[0006] If the second attribute information identical to the first attribute information does not exist, generating the path information of the target page element according to the first attribute information;
[0007] If the second attribute information is the same as the first attribute information, obtaining the first tag information of the target page element and the second tag information of the reference page element;
[0008] If the second tag information identical to the first tag information does not exist, the path information of the target page element is generated according to the first tag information; wherein the path information is used to locate the target page element in the page code document.
[0009] On the other hand, an embodiment of the present application provides a path determination device, the device comprising:
[0010] an acquiring unit, configured to acquire first attribute information of a target page element and second attribute information of a reference page element, wherein the target page element and the reference page element are included in a page code document, and the reference page element and the target page element have the same parent page element;
[0011] a processing unit, configured to generate path information of the target page element according to the first attribute information if the second attribute information identical to the first attribute information does not exist;
[0012] The acquiring unit is further configured to acquire the first tag information of the target page element and the second tag information of the reference page element if the second attribute information that is the same as the first attribute information exists;
[0013] The processing unit is further configured to generate path information of the target page element based on the first tag information if the second tag information identical to the first tag information does not exist; wherein the path information is used to locate the target page element in the page code document.
[0014] Optionally, the processing unit is also used to: determine the parent page element of the target page element; use the parent page element as the new target page element, and execute the acquisition of the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes to determine the path information of the parent page element; determine the path information of the target page element based on the first attribute information or the first tag information, and the path information of the parent page element.
[0015] Optionally, the processing unit is also used to: determine whether the first attribute information is unique in the page code document; if the first attribute information is unique in the page code document, use the first attribute information as the path information of the target page element; if the first attribute information is not unique in the page code document, execute the acquisition of the second attribute information of the reference page element and subsequent processes.
[0016] Optionally, the processing unit is further configured to: if the second tag information identical to the first tag information exists, obtain index information of the target page element;
[0017] generating reference path information of the target page element according to one or more of the first attribute information and the first tag information, and the index information;
[0018] The path information of the target page element is generated according to the reference path information.
[0019] Optionally, the acquisition unit is further configured to: acquire an index array, where the index array is generated according to the position sequence of index page elements in the page code document, the index page elements including: the target page element, and a reference page element corresponding to second attribute information identical to the first attribute information, and / or a reference page element corresponding to second tag information identical to the first tag information;
[0020] The processing unit is further configured to generate index information of the target page element according to an arrangement position of the target page element in the index array.
[0021] Optionally, the acquisition unit is further configured to: acquire identification information of the target page element, wherein the identification information is used to uniquely identify the target page element in the page code document;
[0022] The processing unit is also used to: determine whether the identification information exists in the page code document; if the identification information exists in the page code document, generate the path information of the target page element according to the identification information; if the identification information does not exist in the page code document, execute the acquisition of the first attribute information of the target page element and the second attribute information of the reference page element and the subsequent process.
[0023] Optionally, the processing unit is also used to: when a burying operation is detected for the target page element, send burying indication information containing the path information of the target page element to the client, and the burying indication information is used to instruct the client to monitor the event corresponding to the target page element according to the path information of the target page element, and report event behavior data to the server when the event is monitored.
[0024] Accordingly, an embodiment of the present application provides a computer device, which includes a processor, a communication interface and a memory, wherein the processor, the communication interface and the memory are interconnected, wherein the memory stores a computer program, and the processor is used to call the computer program to execute the path determination method of any possible implementation method described above.
[0025] Accordingly, an embodiment of the present application provides a computer-readable storage medium storing a computer program, and a processor executes the computer program involved in the path determination method of any possible implementation manner described above.
[0026] Accordingly, an embodiment of the present application further provides a computer program product, which includes a computer program or computer instructions. When the computer program or computer instructions are executed by a processor, the steps of the path determination method provided in the embodiment of the present application are implemented.
[0027] Accordingly, an embodiment of the present application also provides a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the path determination method provided in the embodiment of the present application.
[0028] In an embodiment of the present application, the first attribute information of the target page element and the second attribute information of the reference page element are obtained. The target page element and the reference page element have the same parent page element in the page code document. If the second attribute information that is identical to the first attribute information does not exist, the path information of the target page element is generated according to the first attribute information. If the second attribute information that is identical to the first attribute information exists, the first tag information of the target page element and the second tag information of the reference page element are obtained. When the second tag information that is identical to the first tag information does not exist, the path information of the target page element is generated according to the first tag information. By adopting the above method, the automatic and intelligent determination of the page element path can be realized, and the determined page element path can adapt to the changes in the page code document, effectively improving the path validity of the page element. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0030] Figure 1 A schematic diagram of the structure of a document object model tree provided in an embodiment of the present application;
[0031] Figure 2 A network architecture applicable to a path determination method provided in an embodiment of the present application;
[0032] Figure 3 A schematic diagram of a flow chart of a path determination method provided in an embodiment of the present application;
[0033] Figure 4 A schematic diagram of the structure of another document object model tree provided in an embodiment of the present application;
[0034] Figure 5 A flowchart of another path determination method provided in an embodiment of the present application;
[0035] Figure 6 A schematic diagram of a tracking point configuration interface provided in an embodiment of the present application;
[0036] Figure 7 A schematic diagram of another tracking point configuration interface provided in an embodiment of the present application;
[0037] Figure 8 A schematic diagram of the structure of a path determination device provided in an embodiment of the present application;
[0038] Figure 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0040] It should be noted that the terms "first," "second," and so on, used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, technical features designated as "first," "second," and so on may explicitly or implicitly include at least one such feature.
[0041] To better understand the embodiments of the present application, some terms involved in the embodiments of the present application are introduced below:
[0042] XML document: a document generated using the Extensible Markup Language (XML). In this application, an XML document is a page code document generated using XML.
[0043] HTML document: a document generated using the Hyper Text Markup Language (HTML). In this application, an HTML document refers to a page code document generated using HTML.
[0044] XML Path Language (XPath): A language used to locate a section of code within an XML document.
[0045] Tracking: Recording user behavior for subsequent data analysis, such as recording the number of clicks on page elements.
[0046] Crawler: A program or script that automatically crawls the World Wide Web (WWW) information according to certain rules.
[0047] Document Object Model (DOM): A standard programming interface for processing Extensible Markup Language recommended by the World Wide Web Consortium. The Document Object Model parses the page code document into a Document Object Model tree, which contains the page elements and hierarchical structure of the page.
[0048] DOM element: A node in the Document Object Model tree.
[0049] The page element is all the code from the start tag to the end tag in the page code document, usually consisting of the form <start tag>element content< / end tag>. The start tag and the end tag are usually a pair. The element content can be text, tables, and links to pictures, audio and video, other web pages, etc. For example, an instance of a page element: AAA , defines the content of a paragraph (p) in the page code document as: AAA; Attributes of the page element can also be defined in the <start tag>. Attributes usually appear in pairs of an attribute name and an attribute value. For example, an instance of a start tag is:, which defines the background color (bgcolor) of the body of the page element as blue; In addition, page elements can be generated by nesting. For example, an instance of page document code is:
[0050]
[0051]
[0052] In the instance of the page document code, the content from to is a page element A, and at the same time, the content from to is also a page element B, which means that page element B is nested in page element A.
[0053] Please refer to Figure 1 , Figure 1 is the Document Object Model tree generated by DOM using the above instance of the page document code, which includes multiple nodes. The multiple nodes correspond to multiple DOM elements one by one. Each node can be represented by a circle, and one or more of the label, attribute name, attribute, and element content inside the circle. Figure 1 illustrates one of the label (such as html) and the element content (such as AAA); In addition, the nodes are connected by connecting edges to represent the nested relationship between DOM elements. For example, the node corresponding to html is the parent node of the node corresponding to head, which means that the page element corresponding to html nests the page element corresponding to head; A parent node can have any number of child nodes. Nodes at the same level have the same parent node, and the top node is the root node (there is no parent node).
[0054] In the prior art, DOM can parse the page document code into Figure 1 The document object model tree described above uses the nested relationship of DOM elements in the document object model tree to generate a unique path to the DOM element. Usually, all nodes at the same level (with the same parent node) are treated as an array with an index value starting from 1. The xpath of the DOM element is generated using the index value of the current node corresponding to the DOM element in the same level, for example Figure 1 The index value of body in is 2, and the xpath of the DOM element corresponding to body can be expressed as body[2]. In addition, the entire path from the root node to the current node in the document object model tree will be calculated, for example, Figure 1 The unique path of the DOM element corresponding to node a is / / html / / body / / p / / a. It can be seen that in the prior art, when a DOM element is enhanced or reduced at the upper or lower level, or when the order of the DOM elements is changed, the unique path of the DOM element will change.
[0055] It should be noted that the above Figure 1 The nodes in the example document object model tree (i.e., DOM elements) represent one of the attributes (which can be attribute names or attribute values), element content or tags in the page elements. In the present application, the nodes in the document object model tree represent page elements. The path determination method proposed in the present application determines the unique path of the page element, and the determined unique path can adapt to changes in the page code document. It will not cause the unique path of the page element to become invalid and the page element to be unable to be located due to the enhancement or reduction of the page element by the superior or the same level. It has high path validity and can be applied to various fields or scenarios such as cloud technology, artificial intelligence, blockchain, Internet of Vehicles, smart transportation, smart home, etc. Its detailed implementation process is described in detail through the following embodiments.
[0056] In order to realize the automation and intelligence of determining the path of page elements, and effectively improve the path validity of page elements, the embodiment of the present application proposes a path determination method. The path determination method can be implemented based on cloud technology. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the application of cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, each item may have its own identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0057] In feasible embodiments, the path determination method provided in the embodiments of the present application may also be implemented based on artificial intelligence (AI) and / or blockchain technology. Specifically, it may involve one or more of the distributed storage and big data processing technologies within the foundational AI technologies. For example, the generated path information may be stored in a distributed manner across multiple independent devices. In another example, the data required to execute the path determination method may be stored in the form of blocks on a blockchain; the data generated by executing the path determination method (e.g., page code documents, path information, etc.) may be stored in the form of blocks on a blockchain; and the computer device executing the path determination method may be a node device in a blockchain network.
[0058] The path determination method provided in the embodiment of the present application can be applied to Figure 2 The network architecture shown. Figure 2 The computer device 20 shown can be a server or terminal with data processing capabilities. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device, smart home appliance, in-vehicle terminal, etc., but is not limited to these. Figure 2 The terminal 21 is connected to the computer device 20 via a network. The path determination method provided in the embodiment of the present application can be executed by the computer device 20, specifically:
[0059] The computer device 20 obtains the first attribute information of the target page element and the second attribute information of the reference page element. The target page element and the reference page element are included in the page code document and have the same parent page element. If the second attribute information that is the same as the first attribute information does not exist, the path information of the target page element is generated according to the first attribute information. If the second attribute information that is the same as the first attribute information exists, the first tag information of the target page element and the second tag information of the reference page element are obtained, and when the second tag information that is the same as the first tag information does not exist, the path information of the target page element is generated according to the first tag information. This can realize the automation and intelligence of determining the path of the page element, and the determined page element path can adapt to the changes of the page code document, thereby improving the effectiveness of the path of the page element.
[0060] In one embodiment, the path information of the target page element can be applied in the field of tracking points. Optionally, the computer device 20 can send the path information of the target page element to the client deployed on the terminal 21. When the client monitors the event of the page element, it can determine whether to report the event behavior data to the computer device 20 based on whether the path information of the page element matches the path information of the target page element. If it matches the path information of the target page element, the event behavior data is reported to the computer device 20, for example, when a click event for the target page element is monitored, it is reported to the computer device 20.
[0061] In a feasible embodiment, the path information of the target page element can also be applied in the field of web crawlers. For example, the path information of the target page element can be used to locate the target page element in the page code document, and the event corresponding to the target page element can be automatically triggered to crawl network resources.
[0062] It can be understood that the network architecture diagram described in the embodiment of the present application is for the purpose of more clearly illustrating the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0063] The above briefly introduces the path determination method provided in the embodiment of the present application. The specific implementation of the path determination method is described in detail below.
[0064] See also Figure 3 , Figure 3 This is a flow chart of a path determination method provided in an embodiment of the present application. The path determination method includes but is not limited to the following steps:
[0065] S301. Obtain first attribute information of a target page element and second attribute information of a reference page element, wherein the target page element and the reference page element are included in a page code document, and the reference page element and the target page element have the same parent page element.
[0066] In an embodiment of the present application, a page code document is used to present (or render) a page, and generally includes one or more page elements. A target page element, a reference page element, and a parent page element are all included in the page code document. The target page element is any page element in the page code document, and the reference page element and the parent page element are page elements in the page code document other than the target page element. The target page element and the reference page element are nested in the parent page element (i.e., the target page element and the reference page element have the same parent page element, and the parent page element may correspond to the above-mentioned parent node). The page code document may be an XML document or an HTML document, etc.
[0067] In an embodiment of the present application, attribute information provides additional information for a page element. For example, "class" specifies the class name of the page element, "style" specifies the inline style of the page element, and "title" specifies additional information about the page element (which can be displayed in a tooltip). The attribute information usually appears in pairs of attribute names (for example, "class," "style," and "title" are attribute names) and attribute values. The first attribute information of the target page element and the second attribute information of the reference page element include the same attribute name, and the attribute value corresponding to the attribute name is not uniquely corresponding to the page element. That is, for the same attribute name, multiple page elements can have the same attribute value.
[0068] In one embodiment, the computer device determines the path information of the target page element from a global perspective, specifically: obtaining the first attribute information of the target page element, and determining whether the first attribute information is unique in the page code document; if the first attribute information is unique in the page code document, the first attribute information is used as the path information of the target page element; if the first attribute information is not unique in the page code document, the second attribute information of the reference page element and subsequent processes in S301 are obtained.
[0069] In an embodiment of the present application, the path information of the page element is used to locate the position of the page element in the page code document (i.e., a unique path). When the first attribute information is unique in the page code document, the target page element can be uniquely determined in the page code document based on the first attribute information, and the first attribute information can be used as the path information of the target page element; when the first attribute information is not unique in the page code document, there are multiple page elements (including the target page element) including the first attribute information, which will result in the inability to uniquely determine the target page element in the page code document, that is, the path information of the target page element cannot be determined globally, then the second attribute information of the reference page element in S301 and the subsequent process are executed to determine the path information of the target page element in the hierarchy.
[0070] In another embodiment, the computer device determines the path information of the target page element from a global perspective, specifically: the computer device obtains identification information of the target page element, uses the identification information in the page code document to uniquely identify the target page element, and determines whether the identification information exists in the page code document. If the identification information exists in the page code document, the path information of the target page element is generated based on the identification information. If the identification information does not exist in the page code document, the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes in S301 are executed to determine the path information of the target page element in the hierarchy.
[0071] In an embodiment of the present application, the identification information is used to uniquely identify the page element, and may include the attribute name id and the attribute value corresponding to the attribute name id, or include the attribute value corresponding to the attribute name id, because the attribute value corresponding to the attribute name id is unique in the page code document. When the identification information of the target page element exists in the page code document, since the identification information of the target page element is unique in the page code document, the target page element can be uniquely determined, and the identification information of the target page element can be used as the path information of the target page element; when the identification information of the target page element does not exist in the page code document, that is, the path information of the target page element cannot be determined globally through the identification information, then the first attribute information of the target page element and the second attribute information of the reference page element and the subsequent process in S301 are executed to determine the path information of the target page element in the hierarchy.
[0072] S302: If the second attribute information identical to the first attribute information does not exist, generate path information of the target page element according to the first attribute information.
[0073] In one embodiment, when the computer device determines that there is no second attribute information that is identical to the first attribute information, the first attribute information indicating that the target page element is unique in the hierarchy to which it belongs may be used as an identifier that can uniquely identify the target page element in the hierarchy to which the target page element belongs (for ease of subsequent description, the identifier that uniquely identifies the target page element in the hierarchy to which the target page element belongs is referred to as the hierarchy identifier of the target page element). The hierarchy to which the target page element belongs includes the target page element, and the other page elements included in the hierarchy have the same parent page element as the target page element.
[0074] Furthermore, the path information of the target page element is generated based on the first attribute information, specifically: the parent page element of the target page element is determined, the parent page element is used as the new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are obtained to determine the path information of the parent page element, and the path information of the target page element is determined based on the first attribute information and the path information of the parent page element.
[0075] In an embodiment of the present application, the path information of the parent page element can uniquely identify the parent page element in the page code document, and the path information of the parent page element is combined with the first attribute information as the path information of the target page element, so that the parent page element can be determined first based on the path information of the parent page element, and then the target page element can be determined from the next level of the parent page element based on the first attribute information. In one embodiment, when combining the path information of the parent page element with the first attribute information, they can be combined in a sequential relationship. For example, the path information of the final target page element can be expressed as: path information of the parent element > first attribute information, which can improve the readability of the path information. Among them, the next level of the parent page element is the level to which the above-mentioned target page element belongs.
[0076] It should be noted that when taking the parent page element as the new target page element and obtaining the path information of the parent page element, if the path information of the parent page element cannot be determined globally, it is necessary to obtain the hierarchical identifier of the parent page element according to steps S301-S304, and determine the parent page element of the previous level (hereinafter referred to as the second parent page element) of the parent page element (hereinafter referred to as the first parent page element), take the second parent page element as the new target page element, determine the path information of the second parent page element, and generate the path information of the first parent page element based on the path information of the second parent page element and the hierarchical identifier of the first parent page element.
[0077] According to the existing technology, the path generated will include all nodes from the root node to the current node, for example, #app>.box>.item>.time-bars>span. From the above description, it can be seen that the embodiment of the present application uses a recursive upward method to find the shortest path to the target page element, so the previous level or multiple levels of optimization points can be optimized. For example, the first three levels of #app>.box>.item>.time-bars>span can be optimized, leaving only .time-bars>span. Therefore, the present application can only be affected by structural changes of a limited number of layers, can adapt to changes in page code documents, and improve the path validity of page elements.
[0078] S303: If the second attribute information that is the same as the first attribute information exists, obtain the first tag information of the target page element and the second tag information of the reference page element.
[0079] In one embodiment, the computer device determines that there is second attribute information that is the same as the first attribute information, indicating that the first attribute information is not unique in the hierarchy to which it belongs, and the first attribute information cannot uniquely identify the target page element in the hierarchy to which the target page element belongs, and further obtains the hierarchy identifier of the target page element based on the tag.
[0080] In an embodiment of the present application, the first tag information is the start tag or end tag included in the target page element (because the content of the start tag and the end tag are the same), and the second tag information is the start tag or end tag included in the reference page element.
[0081] In one embodiment, if the target page element does not have the first attribute information, the steps of obtaining the first tag information of the target page element and the second tag information of the reference page element and subsequent steps may be directly executed in S303 .
[0082] S304. If the second tag information identical to the first tag information does not exist, generate path information of the target page element according to the first tag information; wherein the path information is used to locate the target page element in the page code document.
[0083] In one embodiment, when the computer device determines that there is no second tag information that is identical to the first tag information, the first tag information indicating the target page element is unique in the hierarchy to which it belongs, and the first tag information can be used as an identifier that can uniquely identify the target page element in the hierarchy to which the target page element belongs (i.e., the hierarchical identifier of the target page element).
[0084] In one embodiment, the path information of the target page element is generated based on the first tag information, specifically: the parent page element of the target page element is determined, the parent page element is used as the new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and the subsequent process are obtained to determine the path information of the parent page element, and the path information of the target page element is determined based on the first tag information and the path information of the parent page element.
[0085] In an embodiment of the present application, the path information of the parent page element and the first tag information are combined as the path information of the target page element, so that the parent page element can be determined first based on the path information of the parent page element, and then the target page element can be determined from the next level of the parent page element based on the first attribute information.
[0086] Through the embodiments of the present application, a recursive upward approach can be used to find the shortest unique path to the target page element, so that it is only affected by structural changes in a limited number of layers, can adapt to changes in page code documents, and improve the path validity of page elements.
[0087] In one embodiment, if the computer device determines that there is second tag information that is the same as the first tag information, it obtains the index information of the target page element, generates reference path information of the target page element based on one or more of the first attribute information and the first tag information, and the index information, and generates path information of the target page element based on the reference path information.
[0088] When the hierarchical identifier of the target page element in the hierarchy cannot be directly determined using the first attribute information and the first tag information, the page elements of the same type at the same hierarchy can be used as an array to obtain the index value of the page element, and the hierarchical identifier of the target page element can be determined based on the index value. The same type includes one or both of the same attribute information and the same tag information, that is, the same attribute information, the same tag information, or the same attribute information and the same tag information.
[0089] In one embodiment, the index information of the target page element is obtained, specifically: an index array is obtained, the index array is generated according to the position order of the index page elements in the page code document, and the index information of the target page element is generated according to the arrangement position of the target page element in the index array.
[0090] In an embodiment of the present application, when the same type includes the same attribute information, the index page element includes: a target page element, and a reference page element corresponding to the second attribute information that is the same as the first attribute information; when the same type includes the same tag information, the index page element includes: a target page element, and a reference page element corresponding to the second tag information that is the same as the first tag information; when the same type includes the same attribute information and the same tag information, the index page element includes: a target page element, a reference page element corresponding to the second attribute information that is the same as the first attribute information, and a reference page element corresponding to the second tag information that is the same as the first tag information.
[0091] When the same category includes the same attribute information and the same tag information, the index page element may include a reference page element whose second attribute information is the same as the first attribute information, and whose second tag information is the same as the first tag information. Therefore, in a feasible embodiment, the index page element may also include: a target page element, and a reference page element that is the same as the first attribute information and the first tag information, which can further constrain the value range of the index value corresponding to the index information.
[0092] See Figure 4 ,against Figure 4 For the target page element button2, the index array is [button1, button2], and the index value is the position order of the target page element in the index array. Then the position order of the target page element button2 in [button1, button2] is 2, and the index information of the target page element is the index value 2.
[0093] In one embodiment, the index value can also start from any value, and the index information of the target page element is generated based on the position order of the target page element in the index array. For example, if the index value starts from 0, the position order of the target page element button2 in [button1, button2] is 1.
[0094] In one embodiment, when the same type includes the same attribute information, the first attribute information and the index information are combined into the reference path information of the target page element (the reference path information can be understood as the aforementioned hierarchical identifier); when the same type includes the same tag information, the first tag information and the index information are combined into the reference path information of the target page element; when the same type includes the same attribute information and the same tag information, one or more of the first attribute information and the first tag information, and the index information are combined into the reference path information of the target page element. For example, Figure 4The reference path information of the target page element button2 can be button:nth-of-type(2), where nth-of-type(2) indicates that the index value is 2 and button is the first attribute information.
[0095] Through this embodiment, index values can be determined based on page elements of the same type, so that the generated path is not affected by the increase or decrease of page elements of other types, thereby adapting to changes in page code documents and effectively improving the path validity of page elements.
[0096] In an embodiment of the present application, a unique path of the target page element is first searched globally. When a unique path does not exist globally, the hierarchical identifier of the target page element in the hierarchy is obtained. At the same time, a unique path of the parent page element is searched, and the unique path of the target page element is obtained based on the unique path of the parent page element and the hierarchical identifier of the target page element. A reverse regression method is used to obtain the shortest path, which can realize the automation and intelligence of determining the path of the page element, and the determined path of the page element can adapt to changes in the page code document, effectively improving the path validity of the page element.
[0097] See Figure 5 , Figure 5 A flow chart of another path determination method provided in an embodiment of the present application. The implementation process of the path determination method is as follows: searching for the attribute ID of the target page element (including the attribute name id and the attribute value corresponding to the attribute name id); determining whether the attribute ID of the target page element is globally unique. If the attribute ID is globally unique, the attribute ID is used as the path information of the target page element. If the attribute ID is not globally unique, the attribute CLASS of the target page element (including the attribute name class and the attribute value corresponding to the attribute name class) is searched. If the attribute CLASS of the target page element is not found, skipping Figure 5 The steps of determining whether the attribute CLASS is globally unique and determining whether the attribute CLASS is unique within the hierarchy to which it belongs are as follows. Determining whether the attribute ID of the target page element is globally unique is specifically as follows: determining whether the attribute name id of the target page element exists. If the attribute name id exists, the attribute ID is globally unique; if the attribute ID does not exist, the attribute ID is globally non-unique.
[0098] If the attribute CLASS of the target page element is found, determine whether the attribute CLASS of the target page element is globally unique. If the attribute CLASS of the target page element is globally unique, use the attribute CLASS as the path information of the target page element. If the attribute CLASS of the target page element is not globally unique, determine whether the attribute CLASS of the target page element is unique in the hierarchy to which the target page element belongs. Determine whether the attribute CLASS of the target page element is globally unique by specifically determining whether the attribute value corresponding to the attribute name class of the target page element is globally unique. If the attribute value corresponding to the attribute name class is globally unique, determine that the attribute CLASS of the target page element is globally unique. If the attribute value corresponding to the attribute name class is not globally unique, determine that the attribute CLASS of the target page element is globally non-unique.
[0099] Determine whether the attribute CLASS of the target page element is unique in the hierarchy to which the target page element belongs. If the attribute CLASS is unique in the hierarchy to which the target page element belongs, take the parent page element as the new target page element, continue to search upward for the path information of the parent page element, and combine the path information of the parent page element and the attribute CLASS of the target page element into the path information of the target page element. If the attribute CLASS is not unique in the hierarchy to which the target page element belongs, determine whether the label of the target page element is unique in the hierarchy to which the target page element belongs. Specifically, determine whether the attribute CLASS of the target page element is unique in the hierarchy to which the target page element belongs: if the attribute value corresponding to the attribute name class of the target page element is unique in the hierarchy to which the target page element belongs, determine that the attribute CLASS is unique in the hierarchy to which the target page element belongs; if the attribute value corresponding to the attribute name class of the target page element is not unique in the hierarchy to which the target page element belongs, determine that the attribute CLASS is not unique in the hierarchy to which the target page element belongs.
[0100] If the label of the target page element is unique in the hierarchy to which the target page element belongs, the parent page element is used as the new target page element, and the path information of the parent page element is continued to be searched upward, and the path information of the parent page element and the label of the target page element are combined into the path information of the target page element; if the label is not unique in the hierarchy to which the target page element belongs, the reference path information of the target page element is determined, specifically: the index value of the target page element is obtained, the reference path information of the target page element is generated according to the index value, the parent page element is used as the new target page element, and the path information of the parent page element is continued to be searched upward, and the path information of the parent page element and the reference path information of the target page element are combined into the path information of the target page element.
[0101] In one embodiment, developers can Figure 6 In the tracking configuration interface shown, the visual tracking is performed on the displayed page, specifically: select the page elements in the page, circle the page elements to be tracked, and use the path determination method of this application to automatically generate the path information of the page elements to be tracked, such as circle the page elements to be tracked. Figure 6 The applet in the Figure 6 The first configuration sub-interface indicated by 61 can be used to enter the corresponding event name (Chinese name and English name), trigger time, and effective page (the page where the page element is located, which can be one or more pages). The #HomesPlates>span displayed in the first configuration sub-interface is the path information of the page element generated by the path determination method of the present application. Among them, the page displayed in the tracking configuration interface can be generated by inputting the URL of the page.
[0102] In one embodiment, you can also configure custom attributes for the circled page elements in the tracking configuration interface, and use the custom attributes to supplement the event itself. Specifically, developers can circle custom attributes (which can be understood as page elements associated with the circled page elements) in the tracking configuration interface. For example, in the past 7 days, Figure 7 The second configuration sub-interface indicated by 71 can be used to fill in the name (Chinese name and English name), data type (such as string), and current content of the custom attribute. The .Time-bars>span displayed in the second configuration sub-interface 2 is the path information of the custom attribute generated using the path determination method of this application.
[0103] In one embodiment, after determining the page element and custom attribute of the embedded point, the path information of the effective page, the embedded page element, and the custom attribute can be sent to the client's embedded point SDK (Software Development Kit), so that the embedded point SDK can monitor the events of the target page element in the effective page based on the path information of the embedded page element, and when an event is detected, determine the event behavior data based on the path information of the custom attribute and send the event behavior data to the computer device. For example, the number of clicks on the mini program in the past 7 days can be uploaded.
[0104] In an embodiment of the present application, reverse regression processing is performed based on attribute ID, attribute CLASS and label to obtain the shortest path of the page element, so that the determination of the page element path can be automated and intelligent, and the determined page element path can adapt to changes in the page code document, thereby improving the path validity of the page element.
[0105] The above describes in detail the method of the embodiment of the present application. To facilitate better implementation of the above solution of the embodiment of the present application, the following provides a device of the embodiment of the present application. Figure 8 , Figure 8 FIG. 8 is a schematic structural diagram of a path determination device provided by an exemplary embodiment of the present application. The path determination device 80 may include:
[0106] An acquiring unit 801 is configured to acquire first attribute information of a target page element and second attribute information of a reference page element, wherein the target page element and the reference page element are included in a page code document, and the reference page element and the target page element have the same parent page element.
[0107] The processing unit 802 is configured to generate path information of the target page element according to the first attribute information if the second attribute information identical to the first attribute information does not exist;
[0108] The acquiring unit 801 is further configured to acquire the first tag information of the target page element and the second tag information of the reference page element if the second attribute information that is the same as the first attribute information exists;
[0109] The processing unit 802 is further configured to generate path information of the target page element based on the first tag information if the second tag information identical to the first tag information does not exist; wherein the path information is used to locate the target page element in the page code document.
[0110] In one embodiment, the processing unit 802 is specifically configured to:
[0111] Determine the parent page element of the target page element;
[0112] The parent page element is used as a new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are performed to determine the path information of the parent page element;
[0113] The path information of the target page element is determined according to the first attribute information or the first tag information and the path information of the parent page element.
[0114] In one embodiment, the processing unit 802 is specifically configured to:
[0115] Determine the parent page element of the target page element;
[0116] The parent page element is used as a new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are performed to determine the path information of the parent page element;
[0117] The path information of the target page element is determined according to the first attribute information or the first tag information and the path information of the parent page element.
[0118] In one embodiment, the processing unit 802 is specifically configured to:
[0119] If the second tag information is the same as the first tag information, obtaining the index information of the target page element;
[0120] generating reference path information of the target page element according to one or more of the first attribute information and the first tag information, and the index information;
[0121] The path information of the target page element is generated according to the reference path information.
[0122] In one embodiment, the acquiring unit 801 is specifically configured to:
[0123] Obtaining an index array, where the index array is generated according to the position order of index page elements in the page code document, the index page elements including: the target page element, and a reference page element corresponding to second attribute information identical to the first attribute information, and / or a reference page element corresponding to second tag information identical to the first tag information;
[0124] The processing unit 802 is specifically configured to:
[0125] The index information of the target page element is generated according to the arrangement position of the target page element in the index array.
[0126] In one embodiment, the acquiring unit 801 is specifically configured to:
[0127] Obtaining identification information of the target page element, where the identification information is used to uniquely identify the target page element in the page code document;
[0128] The processing unit 802 is specifically configured to:
[0129] Determining whether the identification information exists in the page code document;
[0130] If the identification information exists in the page code document, generating the path information of the target page element according to the identification information;
[0131] If the identification information does not exist in the page code document, the steps of obtaining the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are executed.
[0132] In one embodiment, the processing unit 802 is specifically configured to:
[0133] When a tracking operation is detected for the target page element, tracking indication information containing the path information of the target page element is sent to the client. The tracking indication information is used to instruct the client to monitor the event corresponding to the target page element according to the path information of the target page element, and report event behavior data to the server when the event is monitored.
[0134] It can be understood that the functions of the various functional units of the path determination device described in the embodiments of the present application can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can refer to the relevant description of the above method embodiments and will not be repeated here.
[0135] In this embodiment, the first attribute information of the target page element and the second attribute information of the reference page element are obtained. The target page element and the reference page element are included in the page code document and have the same parent page element. If there is no second attribute information that is identical to the first attribute information, the path information of the target page element is generated according to the first attribute information. If there is second attribute information that is identical to the first attribute information, the first tag information of the target page element and the second tag information of the reference page element are obtained. When there is no second tag information that is identical to the first tag information, the path information of the target page element is generated according to the first tag information. This can effectively improve the path validity of the page element.
[0136] like Figure 9 As shown, Figure 9 This is a schematic diagram of the structure of a computer device provided by an embodiment of the present application. The internal structure of the computer device 90 is as follows: Figure 9 As shown, it includes: one or more processors 901, memory 902, and communication interface 903. The processor 901, memory 902, and communication interface 903 can be connected via a bus 904 or other means. The embodiment of the present application takes the connection via the bus 904 as an example.
[0137] The processor 901 (also known as the CPU (Central Processing Unit)) is the computing and control core of the computer device 90. It can interpret various instructions within the computer device 90 and process various data within the computer device 90. For example, the CPU can interpret power on / off commands sent by the user to the computer device 90 and control the computer device 90 to perform power on / off operations. Another example is that the CPU can transmit various interactive data between the internal components of the computer device 90, etc. The communication interface 903 can optionally include a standard wired interface or a wireless interface (such as Wi-Fi or a mobile communication interface), which is controlled by the processor 901 to send and receive data. The memory 902 (Memory) is a storage device within the computer device 90 for storing computer programs and data. It is understood that the memory 902 here can include both the built-in memory of the computer device 90 and the extended memory supported by the computer device 90. The memory 902 provides storage space for the operating system of the computer device 90, which may include but is not limited to Windows systems, Linux systems, etc., but this application is not limited to this. Specifically, the processor 901 executes the following operations by running the computer program stored in the memory 902:
[0138] Acquire first attribute information of a target page element and second attribute information of a reference page element, wherein the target page element and the reference page element are included in a page code document, and the reference page element and the target page element have the same parent page element;
[0139] If the second attribute information identical to the first attribute information does not exist, generating the path information of the target page element according to the first attribute information;
[0140] If the second attribute information is the same as the first attribute information, obtaining the first tag information of the target page element and the second tag information of the reference page element;
[0141] If the second tag information identical to the first tag information does not exist, the path information of the target page element is generated according to the first tag information; wherein the path information is used to locate the target page element in the page code document.
[0142] In one embodiment, the processor 901 is specifically configured to:
[0143] Determine the parent page element of the target page element;
[0144] The parent page element is used as a new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are performed to determine the path information of the parent page element;
[0145] The path information of the target page element is determined according to the first attribute information or the first tag information and the path information of the parent page element.
[0146] In one embodiment, the processor 901 is specifically configured to:
[0147] determining whether the first attribute information is unique in the page code document;
[0148] If the first attribute information is unique in the page code document, using the first attribute information as the path information of the target page element;
[0149] If the first attribute information is not unique in the page code document, the second attribute information of the reference page element is obtained and subsequent processes are performed.
[0150] In one embodiment, the processor 901 is specifically configured to:
[0151] If the second tag information is the same as the first tag information, obtaining the index information of the target page element;
[0152] generating reference path information of the target page element according to one or more of the first attribute information and the first tag information, and the index information;
[0153] The path information of the target page element is generated according to the reference path information.
[0154] In one embodiment, the processor 901 is specifically configured to:
[0155] Obtaining an index array, where the index array is generated according to the position order of index page elements in the page code document, the index page elements including: the target page element, and a reference page element corresponding to second attribute information identical to the first attribute information, and / or a reference page element corresponding to second tag information identical to the first tag information;
[0156] The index information of the target page element is generated according to the arrangement position of the target page element in the index array.
[0157] In one embodiment, the processor 901 is specifically configured to:
[0158] Obtaining identification information of the target page element, where the identification information is used to uniquely identify the target page element in the page code document;
[0159] Determining whether the identification information exists in the page code document;
[0160] If the identification information exists in the page code document, generating the path information of the target page element according to the identification information;
[0161] If the identification information does not exist in the page code document, the steps of obtaining the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are executed.
[0162] In one embodiment, the processor 901 is specifically configured to:
[0163] When a tracking operation is detected for the target page element, tracking indication information containing the path information of the target page element is sent to the client. The tracking indication information is used to instruct the client to monitor the event corresponding to the target page element according to the path information of the target page element, and report event behavior data to the server when the event is monitored.
[0164] In a specific implementation, the processor 901, memory 902, and communication interface 903 described in the embodiment of the present application can execute the implementation of the computer device described in a path determination method provided in an embodiment of the present application, and can also execute the implementation described in a path determination device provided in an embodiment of the present application, which will not be repeated here.
[0165] In this embodiment, the first attribute information of the target page element and the second attribute information of the reference page element are obtained. The target page element and the reference page element are included in the page code document and have the same parent page element. If there is no second attribute information that is identical to the first attribute information, the path information of the target page element is generated according to the first attribute information. If there is second attribute information that is identical to the first attribute information, the first tag information of the target page element and the second tag information of the reference page element are obtained. When there is no second tag information that is identical to the first tag information, the path information of the target page element is generated according to the first tag information. This can effectively improve the path validity of the page element.
[0166] Those skilled in the art will appreciate that all or part of the processes in the above-described embodiment method can be implemented by instructing the relevant hardware through a computer program, which can be stored in a computer-readable storage medium. When executed, the computer program can include the processes of the embodiment of the path determination method described above for the data receiving node. Alternatively, the processes can be implemented by instructing the relevant hardware through a second computer program, which can be stored in a computer-readable storage medium. When executed, the computer program can include the processes of the embodiment of the path determination method described above for the data providing node. The readable storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0167] The present application also provides a computer program product, which includes a computer program or computer instructions. When executed by a processor, the computer program or computer instructions implement the steps of the data processing method provided in the present application. The specific implementation method is described above and will not be repeated here.
[0168] The present application also provides a computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the data processing method provided in the present application. The specific implementation method can be found in the previous description and will not be repeated here.
[0169] The above embodiments merely illustrate several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A path determination method, characterized in that: The method comprises: Obtaining first attribute information of a target page element, and if the first attribute information is not unique in the page code document, obtaining second attribute information of a reference page element, wherein the target page element and the reference page element are included in the page code document, and the reference page element and the target page element have the same parent page element; If the second attribute information identical to the first attribute information does not exist, generating the path information of the target page element according to the first attribute information; If the second attribute information is the same as the first attribute information, obtaining the first tag information of the target page element and the second tag information of the reference page element; If the second tag information that is identical to the first tag information does not exist, the path information of the target page element is generated based on the first tag information and the path information of the parent page element of the target page element; wherein the path information is used to locate the target page element in the page code document.
2. The method according to claim 1, characterized in that Generating the path information of the target page element according to the first attribute information or according to the first tag information and the path information of the parent page element of the target page element includes: Determine the parent page element of the target page element; The parent page element is used as a new target page element, and the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are performed to determine the path information of the parent page element; The path information of the target page element is determined according to the first attribute information or the first tag information and the path information of the parent page element.
3. The method according to claim 1 or 2, characterized in that The method further comprises: determining whether the first attribute information is unique in the page code document; If the first attribute information is unique in the page code document, the first attribute information is used as the path information of the target page element.
4. The method according to claim 1, wherein The method further comprises: If the second tag information is the same as the first tag information, obtaining the index information of the target page element; generating reference path information of the target page element according to one or more of the first attribute information and the first tag information, and the index information; The path information of the target page element is generated according to the reference path information.
5. The method according to claim 4, characterized in that The obtaining of index information of the target page element includes: Obtaining an index array, where the index array is generated according to the position order of index page elements in the page code document, the index page elements including: the target page element, and a reference page element corresponding to second attribute information identical to the first attribute information, and / or a reference page element corresponding to second tag information identical to the first tag information; The index information of the target page element is generated according to the arrangement position of the target page element in the index array.
6. The method according to claim 1, characterized in that The method further comprises: Obtaining identification information of the target page element, where the identification information is used to uniquely identify the target page element in the page code document; Determining whether the identification information exists in the page code document; If the identification information exists in the page code document, generating the path information of the target page element according to the identification information; If the identification information does not exist in the page code document, the steps of obtaining the first attribute information of the target page element and the second attribute information of the reference page element and subsequent processes are executed.
7. The method according to claim 1, characterized in that The method further comprises: When a tracking operation is detected for the target page element, tracking indication information containing the path information of the target page element is sent to the client. The tracking indication information is used to instruct the client to monitor the event corresponding to the target page element according to the path information of the target page element, and report event behavior data to the server when the event is monitored.
8. A path determination device, characterized in that: The device comprises: an acquiring unit, configured to acquire first attribute information of a target page element, and if the first attribute information is not unique in the page code document, acquire second attribute information of a reference page element, wherein the target page element and the reference page element are included in the page code document, and the reference page element and the target page element have the same parent page element; a processing unit, configured to generate path information of the target page element according to the first attribute information if the second attribute information identical to the first attribute information does not exist; The acquiring unit is further configured to acquire the first tag information of the target page element and the second tag information of the reference page element if the second attribute information that is the same as the first attribute information exists; The processing unit is also used to generate path information of the target page element based on the first tag information and the path information of the parent page element of the target page element if the second tag information identical to the first tag information does not exist; wherein the path information is used to locate the target page element in the page code document.
9. A computer device, characterized in that: The method comprises a memory, a communication interface, and a processor, wherein the memory, the communication interface, and the processor are interconnected; the memory stores a computer program, and the processor calls the computer program stored in the memory to execute the path determination method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that A computer program is stored, and when the computer program is executed by a processor, the path determination method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that The computer program product includes a computer program or computer instructions, and when the computer program or computer instructions are executed by a processor, the path determination method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Page element positioning method and device
CN104866509A