Web page clustering method and related device
Through the pre-comparison of DOM tree size and the measurement method of hierarchical distribution distance, the problem of low efficiency and unsatisfactory effect of web page clustering in the existing technology is solved, and efficient web page clustering is achieved.
Patent Information
- Application Number
- CN202210094439.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-26
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-01-26
AI Technical Summary
When the existing web page clustering methods calculate the similarity of web pages, the tree edit distance method is inefficient, the tag frequency statistical method has unsatisfactory clustering effect, and it is difficult to meet the needs of clustering efficiency and effect at the same time.
Reduce unnecessary distance calculations through pre-comparison of DOM tree sizes, and propose hierarchical distribution distance as a measure of DOM tree similarity. When clustering web page data, group similar data into one cluster, and set cluster centers. Through comparison between cluster centers Perform clustering.
It improves the execution efficiency of web page clustering and ensures better clustering effects, taking into account the node level and distribution characteristics of the DOM tree.
Smart Images

Figure CN114611038B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of web page clustering, and in particular to a web page clustering method and related equipment. Background Art
[0002] The core of the web page clustering problem is to calculate the similarity between web pages. According to different calculation methods, there are text-based clustering methods and web page structure-based clustering methods. The text content contained in the web page is an intuitive carrier of web page information. The web page content-based clustering method mainly compares the content similarity between web pages as the basis for judging the similarity of web pages. Today's web pages often use more image elements, which reduces the proportion of text, resulting in the text feature information of the web page being unstable. Compared with the text content, the structural information of the web page has a longer update cycle and higher stability. For structure-based web page clustering, the related methods are the tree edit distance method and the label frequency statistics method.
[0003] Among the related methods, the tree edit distance method has the problem of low solution efficiency due to the complex solution process; the label frequency statistics method will lead to unsatisfactory clustering effect due to insufficient consideration of node hierarchy and distribution characteristics. Summary of the invention
[0004] In view of this, the purpose of this application is to propose a web page clustering method and related equipment.
[0005] Based on the above purpose, the present application provides a web page clustering method, including:
[0006] A web page data set to be clustered is obtained, and the following clustering operations are performed in sequence for each web page data to be clustered in the web page data set to be clustered, so as to complete clustering of all web page data to be clustered in the web page data set to be clustered:
[0007] In response to determining that the web page data to be clustered is the first web page to be clustered, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; adding the new cluster to the cluster list;
[0008] In response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center;
[0009] The hierarchical distribution distances between the web page data to be clustered and each of the pre-selected cluster centers are calculated respectively, the hierarchical distribution distances are used to represent the similarity of the document object model DOM tree of the web page; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, the web page data to be clustered is added to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, a new cluster is created, the web page data to be clustered is added to the new cluster, and the web page data to be clustered is set as the cluster center of the new cluster; and the new cluster is added to the cluster list.
[0010] Furthermore, the method further comprises:
[0011] In response to determining that the number of web page data to be clustered for the clustering operation reaches a third threshold, a preset number of web page data to be clustered with the smallest hierarchical distribution distance from the cluster center is selected, and the cluster center and the set of the selected web page data to be clustered are taken as a new cluster. The hierarchical distribution distances between each pair of the web page data to be clustered, including the cluster center, are calculated respectively, and the web page data to be clustered with the smallest hierarchical distribution distance between the other selected web page data to be clustered and the cluster center is taken as the cluster center of the new cluster.
[0012] Furthermore, the step of respectively calculating the hierarchical distribution distance between the web page data to be clustered and each of the pre-selected cluster centers includes:
[0013] The following operations are performed on the web page data to be clustered and each of the pre-selected cluster centers respectively:
[0014] Traversing the DOM tree of the web page data to be clustered, and obtaining a first hierarchical distribution array and a first statistical distribution vector according to node distribution information of the DOM tree of the web page data to be clustered;
[0015] Traversing the DOM tree of the pre-selected cluster center, and obtaining a second hierarchical distribution array and a second statistical distribution vector according to the node distribution information of the DOM tree of the pre-selected cluster center; wherein the hierarchical distribution array is composed of the distribution vectors of each layer in the array, indicating the proportion of the number of each type of nodes in each layer of the DOM tree to the total number of nodes in the layer; and the statistical distribution vector indicates the proportion of the number of nodes in each layer of the DOM tree to the total number of nodes;
[0016] The dimension of the array with smaller dimension in the first level distribution array and the second level distribution array is padded to be the same as the array with larger dimension, so as to obtain a new first level distribution array and a new second level distribution array;
[0017] Calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array;
[0018] Calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector;
[0019] The ratio of the hierarchical similarity to the statistical similarity is used as the hierarchical distribution distance between the web page data to be clustered and the pre-selected cluster center.
[0020] Furthermore, the step of calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array includes:
[0021]
[0022] Among them, C level is the hierarchical similarity, i∈[1,m] represents the current number of rows in the hierarchical distribution array, vec1 level [i],vec2 level [i] represents the distribution vector of the hierarchical distribution array corresponding to the web page data to be clustered and the pre-selected cluster center on the i-th row, c le w is a parameter used to adjust the angle calculation result of the distribution vector; sum is the total amount of weights per layer, w level is the decrease of each layer of weight; vec1 level [i],vec2 level [i] are all distribution vectors with dimension k. For the distance of the i-th layer of the DOM tree vec The calculation formula is as follows:
[0023]
[0024] Among them, W vertex [j] is the weight coefficient of the current node.
[0025] Furthermore, the calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector includes:
[0026] sim distri =c distri (α distri +cos(vec1 distri ,vec2 distri ))
[0027] Among them, sim distri is the statistical similarity, α distri is a constant used to adjust the lower limit of the result, c distri It is a parameter used to adjust the range of distribution similarity settlement results.
[0028] Furthermore, the DOM tree is extracted by the following method:
[0029] Accessing a target webpage through a script browser, and in response to determining that the target webpage has been loaded, obtaining a hypertext markup language HTML document of the target webpage;
[0030] Obtain HTML tags in the HTML document through regular expression matching;
[0031] The nodes corresponding to each HTML tag are generated one by one in the order of the HTML tags to obtain the DOM tree.
[0032] Furthermore, the regular expression matching is performed through a re library.
[0033] Based on the same concept, the present application also provides a web page clustering device, including:
[0034] An acquisition module is configured to acquire a data set of web pages to be clustered;
[0035] The clustering module is configured to perform the following clustering operations in sequence on each of the web page data to be clustered in the web page data set to complete clustering of all the web page data to be clustered in the web page data set to be clustered:
[0036] In response to determining that the web page data to be clustered is the first web page to be clustered, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; adding the new cluster to the cluster list;
[0037] In response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center;
[0038] The hierarchical distribution distances between the web page data to be clustered and each of the pre-selected cluster centers are calculated respectively; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, the web page data to be clustered is added to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, a new cluster is created, the web page data to be clustered is added to the new cluster, and the web page data to be clustered is set as the cluster center of the new cluster; and the new cluster is added to the cluster list.
[0039] Based on the same concept, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods described above when executing the program.
[0040] Based on the same concept, the present application also provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to implement any of the methods described above.
[0041] From the above, it can be seen that the web page clustering method provided by the present application reduces unnecessary distance calculations by pre-comparing the DOM tree size; classifies the web page data of the same type to be clustered into a cluster, and sets the corresponding cluster center, and clusters the web pages to be clustered by comparing the web pages to be clustered with the cluster centers of each existing cluster. Among them: the number of distance calculations is reduced by pre-comparing the DOM tree size; by proposing the definition of hierarchical distribution distance and using it as a method for measuring the degree of similarity of the DOM tree, the proposed method can ensure a better clustering effect while having a higher execution efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0043] Figure 1 A partial HTML code diagram for existing search engines;
[0044] Figure 2 HTML DOM tree diagram for existing search engines;
[0045] Figure 3 This is a flow chart of the web page clustering method according to an embodiment of the present application;
[0046] Figure 4This is a flow chart of the hierarchical distribution distance calculation method of the embodiment of the present application;
[0047] Figure 5 A schematic diagram of a feature conversion process of a DOM tree according to an embodiment of the present application;
[0048] Figure 6 A schematic diagram of the structure of a web page clustering device according to an embodiment of the present application;
[0049] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0051] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0052] As described in the background technology section, the related web page clustering schemes are still difficult to meet the needs of web page clustering efficiency and clustering effect at the same time. A large number of web pages on the Internet are written in HTML (Hyper Text Markup Language). Hypertext is a way of organizing information that can associate text, graphics and other information media in the text. This way of organizing information can break the limitations of physical location and connect information resources distributed in different files or other computers in a random way, which provides great convenience for users to find and retrieve the information they need.
[0053] HTML contains a collection of a series of tags, which unify the document format on the network and connect scattered Internet resources into a logical whole. HTML tags are the most basic units in HTML. Formally, HTML tags are composed of keywords and a pair of angle brackets surrounding the keywords. Usually HTML tags appear in pairs in the form of a start tag and an end tag, and the web page information is written between the two tags. For tags that appear alone, the corresponding web page information is directly assigned in the tag attributes. When a user uses a browser to access a web page, the browser will request the HTML file of the web page from the server where the web page is located. After obtaining the HTML file of the target web page, the browser will render the web page according to the HTML file and finally present the web page to the user. For example Figure 1 The following is a screenshot of some HTML code of a search engine. The part in the angle brackets is a node, which includes the node type (div) and other node attributes, such as jscontroller, class, jsname, etc. In addition, the node contains a child node of type style, and a sibling node of type div. It and the sibling node belong to a parent node of type div.
[0054] DOM is the abbreviation of Document Object Model. In 1998, W3C standardized DOM and has released three versions so far. According to the DOM specification, DOM is an interface that is independent of browsers, platforms, and languages. The DOM interface provides a way to access HTML documents on a web page through a hierarchical object model, allowing programs and scripts to dynamically access and update the content, structure, and style of HTML documents. These hierarchical object models will integrate the tags in the HTML document to form a node tree. The tags, tag attributes, or tag content in the web page document will be represented as nodes on the tree. Reference Figure 2, is the HTML DOM tree of a search engine, which contains html, body, meta, link, title, style, div, and script nodes. In the DOM tree, all nodes can be accessed through JavaScript, so all HTML elements (nodes) can be edited, and elements can be created or deleted at specified locations. Through DOM, access to all elements in an HTML document can be obtained, thereby avoiding users from directly facing huge HTML documents, making it more convenient for users to interact with web pages, and improving the efficiency of web page design and production. By integrating HTML documents into a more regular and ordered tree structure, the DOM tree can more intuitively reflect the structural characteristics of web pages, and can effectively avoid the interference of irrelevant elements such as text, pictures, and videos on the extraction of web page structure. In addition, in the study of web page data, DOM can also help researchers more effectively exclude irrelevant data from web pages and obtain the required information.
[0055] In the process of implementing this application, the applicant discovered that although the tree edit distance is a solution method specifically corresponding to the tree structure, it can comprehensively consider the hierarchy, position and attribute characteristics of the nodes. However, due to the complex structure of the tree itself, the calculation complexity of the tree edit distance is relatively high. The core idea is to realize the conversion between different trees through editing operations, so as to quantify the similarity between different trees. The distance between two trees is defined as the minimum edit distance required to convert tree T1 into tree T2, and a dynamic programming method is designed to solve the edit distance. In the definition of tree edit distance, there are three ways to edit a specific position of a tree: adding specific nodes, deleting specific nodes, and changing the attribute values of nodes. The minimum editing operation required for the conversion of two trees is obtained, which is the edit distance of the two trees. The smaller the distance between the two trees, that is, the fewer edits are required for the conversion between the two trees, which proves that the two trees are more similar in structure. Assume that the series of operations required to convert tree T1 into tree T2 is defined as an operation sequence S = {s1, s2,…, s n}. In order to better describe the editing cost of adding and deleting nodes, γ represents the cost function of the node conversion editing operation, which returns a non-negative number. Therefore, the operation sequence S required to transform the tree T1 into the tree T2 corresponds to the edit distance In addition, the minimum edit distance that needs to be solved is δ(T1, T2) = min{γ(S)}. Unlike the tree edit distance, the tag frequency statistics method mainly considers the attributes (types) of a series of nodes in the DOM tree. According to the statistical characteristics of the types of DOM tree nodes, the DOM tree is converted into a tag frequency feature vector with a smaller dimension. The similarity of the tag frequency feature vectors of two web pages is compared by calculating the vector angle, thereby describing the structural similarity of the two web pages. The tag frequency statistics method analyzes the nodes of the web page DOM tree and clusters them according to the statistical characteristics of the tree node attributes. Although it can effectively reduce the computational complexity, it will have a certain impact on the clustering accuracy due to the neglect of the node hierarchy and position information.
[0056] In view of this, one or more embodiments of the present application provide a web page clustering solution. The technical solutions of each specific embodiment of the present application are described below.
[0057] refer to Figure 3 The web page clustering method of the embodiment of the present application comprises the following steps:
[0058] Step S301: Obtain a web page data set to be clustered, and perform the following clustering operations in sequence for each web page data to be clustered in the web page data set to be clustered, so as to complete clustering of all web page data to be clustered in the web page data set to be clustered:
[0059] In this step, firstly, all the web page data to be clustered need to be obtained, and the data are taken as a set, and clustering operation is performed on each web page data to be clustered in the set in turn.
[0060] Step S302: in response to determining that the web page data to be clustered is the first web page to be clustered, create a new cluster, add the web page data to be clustered to the new cluster, and set the web page data to be clustered as the cluster center of the new cluster; add the new cluster to the cluster list;
[0061] In this embodiment, considering that it is often difficult to determine the number of categories that need to be clustered in the web page clustering problem, the clustering method of the embodiment of the present application does not need to pre-set different types of web page data. A series of clusters will be generated during the clustering process, and each cluster represents a type of web page, so each cluster stores a series of web page data with similar structures. Each cluster has a cluster center, and the web page data to be clustered will perform hierarchical distribution distance calculations with the cluster center of each cluster, thereby reducing unnecessary similarity calculations and improving clustering efficiency.
[0062] Step S303, in response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center;
[0063] In this step, in the process of finding the cluster corresponding to the web page data to be clustered, in order to reduce the cost of unnecessary hierarchical distribution distance calculation, the DOM tree size of the web page data to be clustered is first compared. The size comparison includes the comparison of the number of nodes and the number of DOM tree layers. Only when the difference between the number of nodes and the number of layers of the DOM tree of the web page data to be clustered and the cluster center is less than the preset first threshold, the cluster center is used as the pre-selected cluster center, and the hierarchical distribution distance of the pre-selected cluster center is only calculated subsequently. As an example, through size comparison, the cluster centers with a DOM tree layer number difference of less than 1 layer and a node number difference of less than 10% with the web page data to be clustered are screened out as pre-selected cluster centers.
[0064] Step S304, respectively calculating the hierarchical distribution distance between the web page data to be clustered and each of the pre-selected cluster centers, the hierarchical distribution distance being used to represent the similarity of the document object model DOM tree of the web page; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, adding the web page data to be clustered to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; and adding the new cluster to the cluster list.
[0065] In this step, each web page to be clustered will calculate the hierarchical distribution distance from the cluster center of each cluster in turn, and add it to the smallest cluster less than or equal to the second threshold. If no smallest cluster less than or equal to the second threshold is found, the web page to be clustered will be added to the newly established cluster separately.
[0066] From the above description, it can be seen that the embodiment of the present application classifies the similar web page data to be clustered into a cluster, and sets the corresponding cluster center, and clusters the web pages to be clustered by comparing the web pages to be clustered with the cluster centers of each existing cluster. Among them: by pre-comparing the DOM tree size, the number of distance calculations is reduced; by proposing the definition of hierarchical distribution distance and using it as a measure of the similarity of the DOM tree, the hierarchy, distribution and attribute characteristics of the DOM tree nodes are comprehensively considered, so that the method of this embodiment can ensure a better clustering effect while having a higher execution efficiency.
[0067] In some other embodiments, the web page clustering method described in the aforementioned embodiments also includes: in response to determining that the number of web page data to be clustered for the clustering operation reaches a third threshold, selecting a preset number of web page data to be clustered with the smallest hierarchical distribution distance from the cluster center, taking the cluster center and the set of the selected web page data to be clustered as a new cluster, calculating the hierarchical distribution distance between each pair of the web page data to be clustered including the cluster center, and taking the web page data to be clustered with the smallest hierarchical distribution distance with other selected web page data to be clustered and the cluster center as the cluster center of the new cluster.
[0068] In this embodiment, after creating new clusters for many times and using the web page data to be clustered as the cluster center of the new cluster, the number of clusters in the cluster list will increase, which will affect the subsequent calculations. Therefore, when each web page to be clustered in the clustered web page data set is incrementally calculated in sequence, in the process of clustering the web pages to be clustered, each time the number of web page data to be clustered reaches the third threshold, the cluster center must be fully calculated to reduce the number of clusters in the cluster list and complete the refresh of the cluster list. After the refresh, the count is re-counted to reach the third threshold and then refreshed again, and the cycle is repeated until the clustering of all web page data to be clustered is completed. The third threshold and the preset number can be selected according to the actual situation and are not limited here.
[0069] In some embodiments, the third threshold is 10. After every 10 web pages to be clustered are clustered, the 5 web pages closest to the original cluster center are selected. The 5 web pages and the original cluster center form a set, and the distance between each web page in the set is solved. The one closest to the remaining 4 web pages and the original cluster center is selected as the new cluster center.
[0070] As a specific example, the clustering process can also be described as follows:
[0071] ① Get the web page data w to be clustered. If it is the first web page to be clustered, create a new cluster C and add the web page data w to C. Refresh the cluster center, set it to the newly added web page data w, and add cluster C to the cluster list.
[0072] ②. Based on the comparison between the web page data w and the DOM tree size of each cluster center, a series of pre-selected clusters are selected from the cluster list, and the web page similarity distance between the web page data w and the cluster center of each pre-selected cluster is calculated one by one, and the minimum value is taken. If the minimum value is less than the threshold, the web page data w is added to the pre-selected cluster with the smallest similarity distance. When a certain number of new web pages are added, the cluster class needs to refresh the cluster center;
[0073] ③. If there is no pre-selected cluster with a web page similarity distance lower than the threshold with web page data w, then the web page data w is divided into a new web page, a corresponding cluster is established, web page data w is added to the corresponding new cluster and the cluster center is refreshed;
[0074] ④. Execute in a loop until all web page data are clustered.
[0075] In some other embodiments, reference Figure 4 , the aforementioned embodiment described in which the hierarchical distribution distance between the web page data to be clustered and each of the pre-selected cluster centers is calculated separately, includes:
[0076] S401, performing the following operations on the web page data to be clustered and each of the pre-selected cluster centers respectively:
[0077] Traversing the DOM tree of the web page data to be clustered, and obtaining a first hierarchical distribution array and a first statistical distribution vector according to node distribution information of the DOM tree of the web page data to be clustered;
[0078] S402, traversing the DOM tree of the pre-selected cluster core, and obtaining a second hierarchical distribution array and a second statistical distribution vector according to the node distribution information of the DOM tree of the pre-selected cluster core; wherein the hierarchical distribution array is composed of the distribution vector of each layer in the array, indicating the proportion of the number of each type of node in each layer of the DOM tree to the total number of nodes in the layer; the statistical distribution vector indicates the proportion of the number of nodes in each layer of the DOM tree to the total number of nodes;
[0079] In this embodiment, each line in the hierarchical distribution array corresponds to a distribution vector for each layer in the DOM tree. The distribution vector reflects the node distribution of each layer of the webpage DOM tree, with the node type as the dimension, and the value of each dimension is the number of nodes of the corresponding dimension type in the layer. By calculating layer by layer, the distribution vectors of each layer will be combined into a two-dimensional array, the size of which is the product of the node type and the number of layers of the DOM tree. Assume that the node type set V contains n types = {v1, v2, v3, ... v n}, and a total of m layers of web page DOM tree node set L = {L1, L2, L3, ..., L m}, then the dimension of the hierarchical distribution array generated after calculation is m×n. From the overall perspective, the statistical distribution vector corresponds to the node distribution in each layer of the DOM tree, and each dimension reflects the proportion of the number of nodes in each layer. For a tree with m layers and a total of N nodes, the number of nodes in each layer is n i , i∈[1,m], then the statistical distribution vector corresponding to the tree refer to Figure 5 , which is the feature conversion process of the DOM tree.
[0080] S403, padding the dimension of the smaller array in the first level distribution array and the second level distribution array to be the same as the larger array, to obtain a new first level distribution array and a new second level distribution array;
[0081] In this step, considering that the DOM trees of the two web pages to be calculated (i.e., the web page data to be clustered and the cluster center) may have different numbers of layers, it is first necessary to align the two hierarchical distribution arrays participating in the calculation, and the one with fewer layers will be padded row by row until the sizes of the two hierarchical distribution arrays are consistent.
[0082] S404, calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array;
[0083] In this step, the calculation formula for the hierarchical similarity calculation based on the hierarchical distribution array is as follows:
[0084]
[0085] Where i∈[1,m] refers to the current number of rows in the hierarchical distribution array, vec1 level [i],vec2 level [i] refers to the distribution vector of the hierarchical distribution array corresponding to the two web pages on the i-th row. By calculating the sine value of the angle between the two distribution vectors, the smaller the value between the vectors with close distribution, the greater the c le It is a parameter used to adjust the angle calculation result of the distribution vector. le , thereby adjusting the magnitude of the result.
[0086] w sum is the total amount of layer-by-layer weights, w level is the decreasing amount of weight at each layer. Web pages with similar DOM structures have a higher similarity in the upper structure of the DOM tree, but have certain differences in the lower structure; conversely, non-similar web pages often have certain differences in the upper structure. So we set the corresponding w sum and w level , and let it decrease layer by layer. The higher the structure, the greater the weight calculation result, thus amplifying the structural differences of the upper layer. Conversely, the lower part has a smaller weight, thus reducing its proportion in similar calculation results.
[0087] distance vec (vec1 level [i],vec2 level [i]) calculates the distance between two distribution vectors and provides the basic value of the distance result. Let vec1 level[i],vec2 level [i] are all distribution vectors with dimension k. For the distance of the i-th layer of the web page DOM tree, vec The calculation formula is as follows:
[0088]
[0089] W vertex [j] refers to the weight coefficient of the current node. Different nodes have different importance in reflecting the structure of the web page, so by setting the corresponding weight parameters separately, the structural differences of each layer can be intuitively converted into differences in distance.
[0090] S405, calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector;
[0091] In this step, it is necessary to compare the overall distribution of the DOM trees of the two web pages based on the statistical distribution vector. The node distribution of the DOM tree is an important reflection of the shape of the DOM tree and an important parameter that reflects the structural characteristics of the DOM tree. Since it is difficult to consider the overall distribution of the DOM tree in the process of calculating the hierarchical distribution array, it is necessary to make another comparative calculation of the overall distribution of the tree, so as to make a comprehensive evaluation of the similarity of the DOM tree. The calculation formula of statistical similarity is as follows:
[0092] sim distri =c distri (α distri +cos(vec1 distri ,vec2 distri ))
[0093] By calculating the cosine value of the angle between two distribution vectors, the distribution of two DOM trees can be effectively compared. The closer the distribution is, the closer the calculation result is to 1. Since the cosine value may be small, α distri is a constant used to adjust the lower limit of the result, c distri It is a parameter used to adjust the range of distribution similarity settlement results.
[0094] S406: Using the ratio of the hierarchical similarity to the statistical similarity as the hierarchical distribution distance between the web page data to be clustered and the pre-selected cluster center.
[0095] In this step, the calculation result of the statistical similarity will be used as the denominator to divide the calculation result of the hierarchical distribution array, so as to amplify or maintain the distance result of the hierarchical distribution array according to the similarity of the overall distribution of the two DOM trees. The calculation formula is:
[0096]
[0097] In terms of complexity, for a DOM tree with n nodes, the computational complexity of the tree edit distance calculation method is O(n 3 ), the clustering method based on label frequency generates a fixed-length feature vector related to the label type, and the computational complexity is related to the number of node types and is a constant. The computational complexity of the hierarchical distribution distance of the embodiment of the present application is the product of the number of label types and the number of DOM tree layers. The number of DOM tree layers is somewhat related to the number of tree nodes, but is much smaller than the number of tree nodes.
[0098] In this embodiment, while measuring the differences in the types and numbers of nodes at each layer of the HTML DOM tree, the characteristics of the overall distribution of the DOM tree that are ignored by the tree edit distance are also taken into account. The calculation of the hierarchical distribution distance first requires traversing the DOM tree to generate a hierarchical distribution array and a statistical distribution vector corresponding to the DOM tree. According to the hierarchical distribution array and the statistical distribution vector of the web pages to be compared, the hierarchical distribution distance between the web pages is solved, and the difference in structure between different web pages is reflected by the solution of the hierarchical distribution distance.
[0099] As a specific example, referring to Table 1, in terms of execution speed test, three methods are used to perform 10,000 similarity calculations based on the same data set, and the execution speeds of the three methods are shown in Table 1. It can be seen that the calculation efficiency of the hierarchical distribution distance of the embodiment of the present application is better.
[0100] Table 1 Comparison of execution time of three methods
[0101] method Tree edit distance Hierarchical distribution distance Tag frequency statistics Time (seconds) 142.38 4.53 1.01
[0102] For 4200 groups of manually annotated web page data, based on the web page clustering method of the embodiment of the present application, the performance indicators of the three similarity calculation methods are compared as shown in Table 2. It can be seen that the web page clustering method of the embodiment of the present application can effectively ensure the clustering effect.
[0103] Table 2 Comparison of clustering effects of three methods
[0104] method Hierarchical distribution distance Tag frequency statistics Tree edit distance Accuracy 94.8% 87.6% 94.0% Accuracy 98.1% 87.9% 97.9% Recall 94.4% 87.4% 93.5% Time (seconds) 365 164 6314
[0105] From the above description, it can be seen that the embodiment of the present application maps the HTML DOM tree of the web page into a corresponding hierarchical distribution array and statistical distribution vector, and uses the hierarchical distribution distance to measure the structural similarity between web pages, and finally solves the clustering problem of similar web pages through a clustering method based on the hierarchical distribution distance. While reducing the complexity of web page similarity calculation and improving the solution efficiency, the hierarchical characteristics and distribution characteristics of the web page are comprehensively considered to maintain a high accuracy of clustering.
[0106] In some other embodiments, the DOM tree described in the above embodiments is extracted by the following method:
[0107] Accessing a target webpage through a script browser, and in response to determining that the target webpage has been loaded, obtaining a hypertext markup language HTML document of the target webpage;
[0108] Obtain HTML tags in the HTML document through regular expression matching;
[0109] The nodes corresponding to each HTML tag are generated one by one in the order of the HTML tags to obtain the DOM tree.
[0110] In this embodiment, to extract the structural feature DOM tree of a web page, it is necessary to obtain the HTML document of the web page and analyze it, extract the HTML tags, generate corresponding tree nodes and combine them into an ordered tree.
[0111] In the process of obtaining web page data, a script-controlled browser is often used to access the target web page. After the web page is loaded, the HTML document of the web page returned by the browser is obtained. Under the default settings, after opening the link entered by the user, the script browser will wait for all elements of the web page (such as JS files, pictures, etc.) to be loaded before executing subsequent instructions. After the web page is loaded, the HTML parser is used to parse the code to prevent garbled characters from appearing in the document. After the HTML parsing is completed, a document tree containing HTML tags, tag attributes and text content will be returned.
[0112] Next, the re library is used for regular expression matching. For the ordered tree of web page structure required by the embodiment of the present application, it is only necessary to extract the type of tag as the attribute of the node. The screening process mainly matches all the strings surrounded by two left and right angle brackets in the document through regular expressions. For the filtered tags, the content is matched to exclude the results of non-HTML tags.
[0113] After regular matching and filtering, HTML tags are in order. As long as nodes are generated one by one based on the order, the DOM structure tree of the web page is generated after sequential combination. Every time a complete tag is read, a tree node corresponding to the attribute content is generated. For HTML documents, the first node (root node) must be 'html', and the next node read will be attached to 'html'. For paired tags (such as 'html', ' / html', 'head', ' / head', 'title', ' / title', etc.), it may be a tree node or a leaf node. After matching the start tag of the paired tag, all nodes matched before the end tag are descendants of the tag. After matching the end tag, the next matched tag is inserted under the parent node of the previous end tag and is a brother node of the previous tag (the order is from left to right). For independent tags (such as 'link', 'meta', etc.), it must be a leaf node.
[0114] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.
[0115] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0116] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a web page clustering device.
[0117] refer to Figure 6 , the web page clustering device comprises:
[0118] An acquisition module 601 is configured to acquire a data set of web pages to be clustered;
[0119] The clustering module 602 is configured to perform the following clustering operations in order on each of the web page data to be clustered in the web page data set to be clustered, so as to complete the clustering of all the web page data to be clustered in the web page data set to be clustered:
[0120] In response to determining that the web page data to be clustered is the first web page to be clustered, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; adding the new cluster to the cluster list;
[0121] In response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center;
[0122] The hierarchical distribution distances between the web page data to be clustered and each of the pre-selected cluster centers are calculated respectively; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, the web page data to be clustered is added to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, a new cluster is created, the web page data to be clustered is added to the new cluster, and the web page data to be clustered is set as the cluster center of the new cluster; and the new cluster is added to the cluster list.
[0123] In some other embodiments, the clustering module 602 is also configured to select a preset number of web page data to be clustered with the smallest hierarchical distribution distance from the cluster center in response to determining that the number of web page data to be clustered for the clustering operation reaches a third threshold, use the cluster center and the set of the selected web page data to be clustered as a new cluster, calculate the hierarchical distribution distance between each pair of the web page data to be clustered including the cluster center, and use the web page data to be clustered with the smallest hierarchical distribution distance with other selected web page data to be clustered and the cluster center as the cluster center of the new cluster.
[0124] In some other embodiments, the clustering module 602 is further configured to perform the following operations on the web page data to be clustered and each of the pre-selected cluster centers respectively:
[0125] Traversing the DOM tree of the web page data to be clustered, and obtaining a first hierarchical distribution array and a first statistical distribution vector according to node distribution information of the DOM tree of the web page data to be clustered;
[0126] Traversing the DOM tree of the pre-selected cluster center, and obtaining a second hierarchical distribution array and a second statistical distribution vector according to the node distribution information of the DOM tree of the pre-selected cluster center; wherein the hierarchical distribution array is composed of the distribution vectors of each layer in the array, indicating the proportion of the number of each type of nodes in each layer of the DOM tree to the total number of nodes in the layer; and the statistical distribution vector indicates the proportion of the number of nodes in each layer of the DOM tree to the total number of nodes;
[0127] The dimension of the array with smaller dimension in the first level distribution array and the second level distribution array is padded to be the same as the array with larger dimension, so as to obtain a new first level distribution array and a new second level distribution array;
[0128] Calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array;
[0129] Calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector;
[0130] The ratio of the hierarchical similarity to the statistical similarity is used as the hierarchical distribution distance between the web page data to be clustered and the pre-selected cluster center.
[0131] In some other embodiments, the acquisition module 601 is further configured to access the target webpage through a script browser, and in response to determining that the target webpage has been loaded, acquire a hypertext markup language HTML document of the target webpage;
[0132] Obtain HTML tags in the HTML document through regular expression matching;
[0133] The nodes corresponding to each HTML tag are generated one by one in the order of the HTML tags to obtain the DOM tree.
[0134] In some other embodiments, the acquisition module 601 is further configured to perform regular expression matching through a re library.
[0135] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0136] The device of the above embodiment is used to implement the corresponding web page clustering method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0137] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the web page clustering method described in any of the above embodiments is implemented.
[0138] Figure 7A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0139] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0140] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0141] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0142] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0143] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0144] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0145] The electronic device of the above embodiment is used to implement the corresponding web page clustering method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0146] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the web page clustering method described in any of the above embodiments.
[0147] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0148] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the web page clustering method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0149] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0150] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0151] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0152] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A web page clustering method, characterized in that: include: A web page data set to be clustered is obtained, and the following clustering operations are performed in sequence for each web page data to be clustered in the web page data set to be clustered, so as to complete clustering of all web page data to be clustered in the web page data set to be clustered: In response to determining that the web page data to be clustered is the first web page to be clustered, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; Add the new cluster to the cluster list; In response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center; The hierarchical distribution distance between the web page data to be clustered and each of the pre-selected cluster centers is calculated respectively, and the following operations are performed on the web page data to be clustered and each of the pre-selected cluster centers respectively: Traversing the DOM tree of the web page data to be clustered, and obtaining a first hierarchical distribution array and a first statistical distribution vector according to node distribution information of the DOM tree of the web page data to be clustered; Traversing the DOM tree of the pre-selected cluster center, and obtaining a second hierarchical distribution array and a second statistical distribution vector according to the node distribution information of the DOM tree of the pre-selected cluster center; wherein the hierarchical distribution array is composed of the distribution vectors of each layer in the array, indicating the proportion of the number of each type of nodes in each layer of the DOM tree to the total number of nodes in the layer; and the statistical distribution vector indicates the proportion of the number of nodes in each layer of the DOM tree to the total number of nodes; The dimension of the array with smaller dimension in the first level distribution array and the second level distribution array is padded to be the same as the array with larger dimension, so as to obtain a new first level distribution array and a new second level distribution array; Calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array; Calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector; The ratio of the hierarchical similarity to the statistical similarity is used as the hierarchical distribution distance between the web page data to be clustered and the pre-selected cluster center; The hierarchical distribution distance is used to represent the similarity of the document object model DOM tree of the web page. In response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, the web page data to be clustered is added to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, a new cluster is created, the web page data to be clustered is added to the new cluster, and the web page data to be clustered is set as the cluster center of the new cluster; and the new cluster is added to the cluster list.
2. The method according to claim 1, characterized in that The method further comprises: In response to determining that the number of web page data to be clustered for the clustering operation reaches a third threshold, a preset number of web page data to be clustered with the smallest hierarchical distribution distance from the cluster center is selected, and the cluster center and the set of the selected web page data to be clustered are taken as a new cluster. The hierarchical distribution distances between each pair of the web page data to be clustered, including the cluster center, are calculated respectively, and the web page data to be clustered with the smallest hierarchical distribution distance with other selected web page data to be clustered and the cluster center is taken as the cluster center of the new cluster.
3. The method according to claim 1, characterized in that The step of calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array includes: Among them, C level is the hierarchical similarity, i∈[1,m] represents the current number of rows in the hierarchical distribution array, vec1 level [i],vec2 level [i] represents the distribution vector of the hierarchical distribution array corresponding to the web page data to be clustered and the pre-selected cluster center on the i-th row, c le w is a parameter used to adjust the angle calculation result of the distribution vector; sum is the total amount of weights per layer, w level is the decrease of each layer of weight; vec1 level [i],vec2 level [i] are all distribution vectors with dimension k. For the distance of the i-th layer of the DOM tree vec The calculation formula is as follows: Among them, W vertex [j] is the weight coefficient of the current node.
4. The method according to claim 1, characterized in that: The calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector includes: Yes distri =c distri (α distri +cos(vec1 distri ,vec2 distri )) Among them, sim distri is the statistical similarity, α distri is a constant used to adjust the lower limit of the result, c distri It is a parameter used to adjust the range of distribution similarity settlement results.
5. The method according to claim 1, characterized in that The DOM tree is extracted by: Accessing a target webpage through a script browser, and in response to determining that the target webpage has been loaded, obtaining a hypertext markup language HTML document of the target webpage; Obtain HTML tags in the HTML document through regular expression matching; The nodes corresponding to each HTML tag are generated one by one in the order of the HTML tags to obtain the DOM tree.
6. The method according to claim 5, characterized in that The regular expression matching is performed through the re library.
7. A web page clustering device, characterized in that: include: An acquisition module is configured to acquire a data set of web pages to be clustered; The clustering module is configured to perform the following clustering operations in sequence on each of the web page data to be clustered in the web page data set to complete clustering of all the web page data to be clustered in the web page data set to be clustered: In response to determining that the web page data to be clustered is the first web page to be clustered, creating a new cluster, adding the web page data to be clustered to the new cluster, and setting the web page data to be clustered as the cluster center of the new cluster; Add the new cluster to the cluster list; In response to determining that the web page data to be clustered is not the first web page to be clustered, taking the cluster center in the cluster list whose difference between the document object model DOM tree size of the cluster center and the DOM tree size of the web page data to be clustered is less than a first threshold as a pre-selected cluster center; The hierarchical distribution distance between the web page data to be clustered and each of the pre-selected cluster centers is calculated respectively, and the following operations are performed on the web page data to be clustered and each of the pre-selected cluster centers respectively: Traversing the DOM tree of the web page data to be clustered, and obtaining a first hierarchical distribution array and a first statistical distribution vector according to node distribution information of the DOM tree of the web page data to be clustered; Traversing the DOM tree of the pre-selected cluster core, and obtaining a second hierarchical distribution array and a second statistical distribution vector according to node distribution information of the DOM tree of the pre-selected cluster core; The dimension of the array with smaller dimension in the first level distribution array and the second level distribution array is padded to be the same as the array with larger dimension, so as to obtain a new first level distribution array and a new second level distribution array; Calculating the hierarchical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the distribution vectors of the new first hierarchical distribution array and the new second hierarchical distribution array; Calculating the statistical similarity between the web page data to be clustered and the pre-selected cluster center according to the angle between the first statistical distribution vector and the second statistical distribution vector; The ratio of the hierarchical similarity to the statistical similarity is used as the hierarchical distribution distance between the web page data to be clustered and the pre-selected cluster center; In response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is less than or equal to a second threshold, the web page data to be clustered is added to the cluster corresponding to the smallest hierarchical distribution distance; in response to determining that the smallest hierarchical distribution distance among the hierarchical distribution distances is greater than the second threshold, a new cluster is created, the web page data to be clustered is added to the new cluster, and the web page data to be clustered is set as the cluster center of the new cluster; and the new cluster is added to the cluster list.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable by the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to make a computer execute the method according to any one of claims 1 to 6.
