Method, device, electronic device and storage medium for determining list page
By analyzing the number of jumps of the URL link and the text content and similarity of the target web page, the problem of how to efficiently determine the web page type is solved, the accurate identification of the list page is achieved, and the efficiency of information acquisition is improved.
Patent Information
- Application Number
- CN202210737170.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-06-27
AI Technical Summary
In the era of big data, how to efficiently determine whether a list page exists in a web page, especially by analyzing the text content and similarity of the URL link and the target web page to determine the page type, the existing technology is difficult to accurately distinguish between detailed pages and list pages.
By obtaining the URL link in the current web page, determine the number of jumps, analyze whether the target web page corresponding to each URL link can extract the text content, and calculate the similarity between the URL link and the details page, and determine it according to the preset threshold Whether the target web page is a list page.
It achieves accurate judgment of web page types, improves the efficiency of information acquisition, and ensures that users can quickly identify list pages, thus improving the efficiency of information acquisition.
Smart Images

Figure CN115017430B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a method, device, electronic device and storage medium for determining a list page. Background Art
[0002] In today's big data era, people are increasingly relying on the Internet to obtain data, such as obtaining news information and announcement information from the Internet. Faced with a large amount of public data on the Internet, people have put forward higher requirements for the efficiency of obtaining information from the Internet. In order to improve the efficiency of obtaining information, in related technologies, a list page is usually used to display multiple list items on the list page. Users can click on the list items in the list page to view the details page corresponding to each list item. However, for a page, how to determine whether the page corresponding to the corresponding access link in the page is a list page is very important for improving the efficiency of obtaining information. Summary of the invention
[0003] The present application proposes a method, device, electronic device and storage medium for determining a list page.
[0004] In one aspect, an embodiment of the present application provides a method for determining a list page, the method comprising: obtaining a current web page; obtaining a plurality of first URL links in the current web page; for each first URL link, determining whether text content can be extracted from a target web page corresponding to the first URL link; if the text content can be extracted from the target web page, determining the similarity between the first URL link and a second URL link in the first link set, wherein the second URL link is a URL link corresponding to a detail page; and determining whether the target web page is a list page based on a comparison result of the similarity with a preset similarity threshold.
[0005] In one embodiment of the present application, the current web page is the home page of a specified website, or a page reached by a single click jump or multiple jumps to the home page. Before acquiring multiple first URL links in the current web page, the method further includes:
[0006] Determine whether the jump number of the current web page is less than a preset jump number;
[0007] The step of obtaining a plurality of first URL links in the current webpage includes:
[0008] When the number of jumps of the current web page is less than a preset jump threshold, the step of acquiring a plurality of first URL links in the current web page is performed.
[0009] In one embodiment of the present application, determining whether the target web page is a list page according to a comparison result between the similarity and a preset similarity threshold includes:
[0010] When the comparison result shows that the similarity is greater than a preset similarity threshold, determining that the target web page is a detailed page; or,
[0011] When the comparison result is that the similarity is less than or equal to a preset similarity threshold, it is determined that the target web page is a list page.
[0012] In one embodiment of the present application, after determining that the target web page is a detailed page, the method further includes:
[0013] Add the first URL link to the first link set.
[0014] In one embodiment of the present application, after adding the first URL link to the first link set, the method further includes:
[0015] Determine the median and mode of link lengths of URL links in the first link set;
[0016] If the link length of the first URL link is less than the mode and less than a specified value, the first URL link is removed from the first link set to a second link set, wherein the second link set is used to store URL links corresponding to list pages, and the specified value is a value obtained by multiplying the median and a preset weight coefficient.
[0017] In one embodiment of the present application, the method further includes:
[0018] If no text content is extracted from the target web page, and the length of the link title corresponding to the first URL link is less than a preset length threshold, it is determined that the target web page is a list page.
[0019] In one embodiment of the present application, after determining that the target webpage is a list page, the method further includes:
[0020] The first URL link is added to a second link set, wherein the second link set is used to store URL links corresponding to list pages.
[0021] In one embodiment of the present application, the determining whether the text content can be extracted from the target webpage corresponding to the first URL link includes:
[0022] Obtaining a hypertext markup language code of a target web page corresponding to the first URL link;
[0023] According to the hypertext markup language code, it is determined whether text content can be extracted from the target web page.
[0024] In one embodiment of the present application, determining whether text content can be extracted from the target web page according to the hypertext markup language code includes:
[0025] Determine, according to the hypertext markup language code, a document object model DOM tree corresponding to the current web page, wherein each node in the DOM tree is a page tag in the current web page;
[0026] Obtain multiple paragraph nodes from the DOM tree, wherein the paragraph nodes are nodes corresponding to the paragraph P tag of the page;
[0027] Determine the score corresponding to each paragraph node according to the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node;
[0028] Acquire a target paragraph node with the highest score from the multiple paragraph nodes;
[0029] From the DOM tree, obtain the parent node corresponding to the target paragraph node;
[0030] It is determined whether the parent node is a text node, wherein if the parent node is a text node, it is determined that the text content can be extracted from the target web page.
[0031] The method for determining the list page of the embodiment of the present application, after obtaining the current web page, obtains multiple first URL links in the current web page; for each first URL link, determines whether the text content can be extracted from the target web page corresponding to the first URL link; in the case that the text content can be extracted from the target web page, determines the similarity between the first URL link and the second URL link in the first link set, wherein the second URL link is the URL link corresponding to the details page; and determines whether the target web page is a list page based on the comparison result of the similarity and the preset similarity threshold. Therefore, a method is proposed to determine whether the target web page corresponding to the corresponding URL link in the current web page is a list page by the similarity between the first URL link and the second URL link corresponding to the details page, and accurately determines whether the target web page corresponding to the URL link of the current web page is a list page.
[0032] Another aspect of the present application provides a device for determining a list page, the device comprising:
[0033] The first acquisition module is used to acquire the current web page;
[0034] A second acquisition module, used to acquire multiple first URL links in the current web page;
[0035] A first determination module, for determining, for each of the first URL links, whether text content can be extracted from a target web page corresponding to the first URL link;
[0036] A second determination module is used to determine the similarity between the first URL link and a second URL link in the first link set when the text content can be extracted from the target web page, wherein the second URL link is a URL link corresponding to a detail page;
[0037] The third determination module is used to determine whether the target web page is a list page according to a comparison result between the similarity and a preset similarity threshold.
[0038] In one embodiment of the present application, the current web page is the home page of a specified website, or a page reached by a single click jump or multiple jumps to the home page. Before acquiring multiple first URL links in the current web page, the device further includes:
[0039] A determination module, used to determine whether the jump number of the current web page is less than a preset jump number;
[0040] The second acquisition module is used to execute the step of acquiring multiple first URL links in the current web page when the jump number of the current web page is less than a preset jump threshold.
[0041] In one embodiment of the present application, the third determination module is specifically configured to:
[0042] When the comparison result shows that the similarity is greater than a preset similarity threshold, determining that the target web page is a detailed page; or,
[0043] When the comparison result is that the similarity is less than or equal to a preset similarity threshold, it is determined that the target web page is a list page.
[0044] In one embodiment of the present application, after determining that the target web page is a detailed page, the device further includes:
[0045] The first adding module is used to add the first URL link to the first link set.
[0046] In one embodiment of the present application, after adding the first URL link to the first link set, the apparatus further includes:
[0047] A fourth determination module, used to determine the median and mode of link lengths of URL links in the first link set;
[0048] A removal module is used to remove the first URL link from the first link set to the second link set when the link length of the first URL link is less than the mode and less than a specified value, wherein the second link set is used to store URL links corresponding to list pages, and the specified value is the value obtained by multiplying the median and a preset weight coefficient.
[0049] In one embodiment of the present application, the device further includes:
[0050] The fifth determination module is used to determine that the target web page is a list page if no text content is extracted from the target web page and the length of the link title corresponding to the first URL link is less than a preset length threshold.
[0051] In one embodiment of the present application, after determining that the target webpage is a list page, the device further includes:
[0052] The second adding module is used to add the first URL link to a second link set, wherein the second link set is used to store URL links corresponding to list pages.
[0053] In one embodiment of the present application, the first determining module includes:
[0054] An acquisition unit, used to acquire a hypertext markup language code of a target web page corresponding to the first URL link;
[0055] The determination unit is used to determine whether the text content can be extracted from the target web page according to the hypertext markup language code.
[0056] In one embodiment of the present application, the determining unit is specifically configured to:
[0057] Determine, according to the hypertext markup language code, a document object model DOM tree corresponding to the current web page, wherein each node in the DOM tree is a page tag in the current web page;
[0058] Obtain multiple paragraph nodes from the DOM tree, wherein the paragraph nodes are nodes corresponding to the paragraph P tag of the page;
[0059] Determine the score corresponding to each paragraph node according to the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node;
[0060] Acquire a target paragraph node with the highest score from the multiple paragraph nodes;
[0061] From the DOM tree, obtain the parent node corresponding to the target paragraph node;
[0062] It is determined whether the parent node is a text node, wherein if the parent node is a text node, it is determined that the text content can be extracted from the target web page.
[0063] The device for determining the list page of the embodiment of the present application obtains multiple first URL links in the current web page after obtaining the current web page; for each first URL link, determines whether the text content can be extracted from the target web page corresponding to the first URL link; in the case that the text content can be extracted from the target web page, determines the similarity between the first URL link and the second URL link in the first link set, wherein the second URL link is the URL link corresponding to the details page; and determines whether the target web page is a list page based on the comparison result of the similarity with the preset similarity threshold. Therefore, a method is proposed to determine whether the target web page corresponding to the corresponding URL link in the current web page is a list page by the similarity between the first URL link and the second URL link corresponding to the details page, so as to accurately determine whether the target web page corresponding to the URL link of the current web page is a list page.
[0064] On the other hand, an embodiment of the present application 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, any of the above-mentioned methods for determining a list page of the embodiments of the present application is implemented.
[0065] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned methods for determining a list page of the embodiments of the present application.
[0066] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0068] Figure 1is a flowchart of a method for determining a list page according to an embodiment of the present application;
[0069] Figure 2 is a flowchart of a method for determining a list page according to another embodiment of the present application;
[0070] Figure 3 is a flowchart of a method for determining a list page according to another embodiment of the present application;
[0071] Figure 4 is a flowchart of a method for determining a list page according to another embodiment of the present application;
[0072] Figure 5 is a structural block diagram of a device for determining a list page according to an embodiment of the present application;
[0073] Figure 6 is a structural block diagram of a device for determining a list page according to another embodiment of the present application;
[0074] Figure 7 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0075] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0076] The following describes a method, device, electronic device, and storage medium for determining a list page according to an embodiment of the present application with reference to the accompanying drawings.
[0077] Figure 1 It is a flowchart of a method for determining a list page according to an embodiment of the present application. It should be noted that the method for determining a list page provided in this embodiment is applied to a device for determining a list page, which can be implemented by software and / or hardware, and can be an electronic device or configured in an electronic device. The electronic device in this embodiment can be a PC (Personal Computer), a mobile device, a tablet computer, a terminal device or a server, etc., which is not specifically limited here.
[0078] like Figure 1 As shown, the method for determining the list page includes:
[0079] Step 101, obtaining the current web page.
[0080] As an exemplary implementation, the current web page may be the home page of a designated website.
[0081] As another exemplary implementation, the current web page may be a page reached by jumping to the home page of a designated website once or by multiple jumps.
[0082] It should be noted that the home page of the website jumps to another new web page, indicating that the home page of the website reaches the web page depth of the next level from the current web page level depth. For example, the web page level depth of the home page of the website is zero, and correspondingly, the web page level depth of the web pages corresponding to the multiple URL (Uniform Resource Locator) links on the home page of the website is 1. If the current page is the web page corresponding to the URL link on the home page of the website, then the number of jumps corresponding to the current web page is one. Correspondingly, the web page level depth of the web page corresponding to the URL link on the web page with a web page level depth of 1 is 2. If the current web page is the web page corresponding to the URL link on the web page with a web page level depth of 1, that is, the current web page is the web page obtained by triggering the URL link on the web page with a web page level depth of 1, then the number of jumps corresponding to the current web page is 2.
[0083] The number of times the current web page jumps can be preset.
[0084] Specifically, when the current web page is the home page of the specified website, the hierarchical depth of the current web page is zero, and the home page of the specified website may usually include multiple URL links. Correspondingly, when clicking on any URL link in the home page of the specified website, the current web page jumps to a web page corresponding to the URL link, that is, entering the first level of depth. For a page at the first level of depth, correspondingly, if the user clicks on any URL link in a page at the first level of depth, the web page corresponding to the corresponding URL link will be displayed, that is, entering the second level of depth from the current web page with a web page hierarchical depth of 1. And so on, until the specified Nth level of depth is reached. Among them, the above-mentioned N can be 3, or 4, etc., and the value of the above-mentioned N can be set according to actual needs, and this embodiment does not make specific limitations on this.
[0085] Step 102: Acquire multiple first URL links in the current web page.
[0086] In one embodiment of the present application, no matter the current web page is the home page of a specified website or is a page reached by one click jump or multiple jumps to the home page of the specified website, there may be multiple URL links in the current web page.
[0087] After the current web page is obtained, multiple URL links in the current web page may be obtained and referred to as the first URL link.
[0088] It is understandable that the first URL link may include a link corresponding to a list page and a link corresponding to a detail page. It is also understandable that the first URL link may also include links corresponding to other content such as titles and advertisements.
[0089] As an exemplary implementation, the source code of the current web page may be obtained first, and then the source code of the current web page may be analyzed and processed to obtain multiple URL links in the current web page from the source code of the current web page.
[0090] In one embodiment of the present application, when the number of jumps of the current web page is greater than the preset jump threshold, the probability of obtaining the list page corresponding to the first URL link on the current web page is greatly reduced. In order to avoid wasting resources, before obtaining multiple first URL links in the current web page, it can also be determined whether the number of jumps of the current web page is less than the preset jump number. When the number of jumps of the current web page is less than the preset jump threshold, the step of obtaining multiple first URL links in the current web page is performed. In other words, when it is determined that the number of jumps of the current web page is less than the preset jump threshold, each first URL link on the current web page is processed based on the method provided by the present application.
[0091] Among them, the above-mentioned preset jump threshold is the critical value of the number of jumps pre-set in the determination device of the above-mentioned list page. For example, the above-mentioned preset jump threshold can be 3 times, or 4 times, etc. In actual applications, the value of the preset jump threshold can be set according to actual business needs, and this embodiment does not make any specific limitations on this.
[0092] Step 103: for each first URL link, determine whether the text content can be extracted from the target web page corresponding to the first URL link.
[0093] In one embodiment of the present application, for the obtained multiple first URL links, the multiple first URL links can be sorted according to the order of the multiple first URL links in the current web page to obtain a sorting result, and each first URL link in the sorting result is traversed in reverse order. For the first URL link currently traversed, it is determined whether the text content can be extracted from the target web page corresponding to the first URL link currently traversed.
[0094] Among them, the reverse traversal can give priority to traversing the URL link in the middle and lower part of the current web page. In other words, the reverse traversal can give priority to traversing the URL link corresponding to the body content of the current web page. That is, the reverse traversal can process the URL link corresponding to the body content of the current web page.
[0095] As an exemplary implementation, the hypertext markup language code of the target web page corresponding to the first URL link may be first obtained, and then it is determined whether the text content can be extracted from the target web page according to the hypertext markup language code.
[0096] Step 104: when the text content can be extracted from the target web page, determine the similarity between the first URL link and the second URL link in the first link set.
[0097] The second URL link is a URL link corresponding to the details page.
[0098] In one embodiment of the present application, the first link set may be a set of URL links corresponding to pre-set detail pages.
[0099] In another embodiment of the present application, the first link set may be a set of URL links corresponding to web pages from which the text content can be extracted. In one embodiment of the present application, the first URL link having a higher similarity to the second URL link may be found by calculating the similarity between the first URL link and the second URL link. In this case, the target web page corresponding to the first URL link having a higher similarity to the second URL link is the detail page.
[0100] It should be noted that the similarity between the first URL link and the second URL link can be calculated using a similarity algorithm.
[0101] Step 105: Determine whether the target web page is a list page based on the comparison result between the similarity and a preset similarity threshold.
[0102] Specifically, the comparison result of the similarity between the first URL link and the second URL link and the preset similarity threshold can be divided into two types: the similarity between the two is greater than the preset similarity threshold, and the similarity between the two is less than or equal to the preset similarity threshold.
[0103] As an example, when the comparison result shows that the similarity is greater than a preset similarity threshold, the target web page is determined to be a detailed page.
[0104] As another example, when the comparison result is that the similarity is less than or equal to a preset similarity threshold, it is determined that the target web page is a list page.
[0105] The preset similarity threshold is a pre-set critical value of similarity, for example, the preset similarity threshold can be set to 0.9.
[0106] For example, assuming that the similarity between the two is 0.98, the comparison result at this time is that the similarity 0.98 is greater than the preset similarity threshold 0.9, it can be determined that the target web page corresponding to the first URL link at this time is a detailed page.
[0107] For another example, assuming that the similarity between the two is 0.7, the comparison result at this time is that the similarity 0.7 is less than the preset similarity threshold 0.9, it can be determined that the target web page corresponding to the first URL link at this time is a list page.
[0108] The method for determining the list page of the embodiment of the present application, after obtaining the current web page, obtains multiple first URL links in the current web page; for each first URL link, determines whether the text content can be extracted from the target web page corresponding to the first URL link; in the case that the text content can be extracted from the target web page, determines the similarity between the first URL link and the second URL link in the first link set, wherein the second URL link is the URL link corresponding to the details page; and determines whether the target web page is a list page based on the comparison result of the similarity and the preset similarity threshold. Therefore, a method is proposed to determine whether the target web page corresponding to the corresponding URL link in the current web page is a list page by the similarity between the first URL link and the second URL link corresponding to the details page, and accurately determines whether the target web page corresponding to the URL link of the current web page is a list page.
[0109] Figure 2 It is a flowchart of a method for determining a list page according to another embodiment of the present application.
[0110] like Figure 2As shown, based on any of the above embodiments, in order to accurately determine whether the text content can be extracted from the target web page corresponding to the first URL link, an implementation method of the above step 103 is:
[0111] Step 201 : determining a document object model DOM tree corresponding to the current web page according to a hypertext markup language code, wherein each node in the DOM tree is a page tag in the current web page.
[0112] Among them, Hyper Text Markup Language (HTML) code is the basic element constituting a web page. It is a descriptive markup language that can identify the display mode of the content in the web page through an identifier.
[0113] As an example, the jsoup open source software package can be used to convert the hypertext markup language code into a document object model DOM tree corresponding to the current web page. This open source software package can directly parse the text content of the hypertext markup language code.
[0114] The DOM tree is a node tree model, and each node in the DOM tree is a page tag in the current web page.
[0115] Among them, each page tag in the current web page may include: picture tag, video tag, line break tag, paragraph tag, etc. Each page tag represents a node in the DOM tree.
[0116] Step 202: Get multiple paragraph nodes from the DOM tree, where the paragraph node is a node corresponding to the page tag paragraph P.
[0117] The page tags of each node in the DOM tree can be displayed using identifiers, for example, script tags that define client scripts, link tags that define the relationship between documents and external resources, img tags for images, video tags for videos, br tags for line breaks, td tags for standard cells, and p tags for paragraphs.
[0118] In one embodiment of the present application, each interfering page tag in the current web page can be deleted. For example, interfering page tags such as script tags defining client scripts and link tags defining the relationship between documents and external resources can be deleted.
[0119] Among them, the node corresponding to the paragraph P tag is the paragraph node.
[0120] In one embodiment of the present application, as a possible implementation method, the image img tag and the video video tag can be modified into a paragraph P tag, and the attributes of the original tag are written into the paragraph P tag, and a sentence of standard text content is filled in the paragraph P tag.
[0121] The standard text content may be pre-set text content for filling.
[0122] In one embodiment of the present application, as another possible implementation, two or more line break br tags may be replaced with a paragraph P tag.
[0123] In one embodiment of the present application, as another possible implementation method, the standard cell td tag can be replaced with a paragraph P tag, and all the text in the standard cell td tag can be filled into the paragraph P tag.
[0124] In one embodiment of the present application, after deleting interfering page tags and modifying image img tags, video tags, and standard cell td tags to paragraph P tags, all paragraph P tags are obtained. At this time, the nodes corresponding to all paragraph P tags are all paragraph nodes.
[0125] Step 203: Determine the score corresponding to each paragraph node according to the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node.
[0126] In one embodiment of the present application, before determining the score corresponding to each paragraph node based on the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node, multiple paragraph texts can also be preprocessed. For example, for each paragraph text, it can be determined whether the word count information in the paragraph text exceeds a preset word count threshold. If it exceeds the preset word count threshold, the paragraph text is deleted from the multiple paragraph texts.
[0127] In some exemplary embodiments of the present application, the rule for scoring each paragraph node based on the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node may be: 1 point can be added for every 50 words in the paragraph text corresponding to the paragraph node; if there are less than 50 words, the score is directly 3 points; each comma can add 1 point, and each period can add 5 points.
[0128] The total number of punctuation marks may include the number of commas and the number of periods.
[0129] Step 204: Obtain the target paragraph node with the highest score from the multiple paragraph nodes.
[0130] The target paragraph node refers to the paragraph node with the highest score among multiple paragraph nodes.
[0131] Step 205: Obtain the parent node corresponding to the target paragraph node from the DOM tree.
[0132] In one embodiment of the present application, the parent node corresponding to the target paragraph node may be the parent node of the target paragraph node, or may be the target paragraph node itself.
[0133] Step 206 , determining whether the parent node is a text node, wherein if the parent node is a text node, determining that the target web page can extract text content.
[0134] In one embodiment of the present application, the parent node may or may not be a text node. If it is a text node, it means that the target web page corresponding to the parent node can extract text content, that is, the target web page is a detail page.
[0135] Figure 3 It is a flowchart of a method for determining a list page according to another embodiment of the present application.
[0136] like Figure 3 As shown, the method for determining the list page may specifically include:
[0137] Step 301, obtaining the current web page.
[0138] Step 302: Acquire multiple first URL links in the current web page.
[0139] Step 303: for each first URL link, determine whether the text content can be extracted from the target web page.
[0140] The specific implementation of steps 301 to 303 can be found in the relevant description of the above embodiment and will not be repeated here.
[0141] Step 304: when the text content can be extracted from the target web page, determine the similarity between the first URL link and the second URL link in the first link set.
[0142] Step 305: If the text content cannot be extracted from the target web page and the length of the link title corresponding to the first URL link is less than a preset length threshold, it is determined that the target web page is a list page.
[0143] In one embodiment of the present application, if it is determined that the text content cannot be extracted from the target web page, it means that in step 206, the parent node is not a text node.
[0144] In one embodiment of the present application, it is also possible to continue to determine whether the length of the link title corresponding to the first URL link is less than a preset length threshold, so as to determine whether the target web page is a list page.
[0145] Specifically, if the length of the link title corresponding to the first URL link at this time is less than the preset length threshold, it can be determined that the target web page is a list page. If the length of the link title corresponding to the first URL link at this time is not less than the preset length threshold, it cannot be determined that the target web page is a list page.
[0146] The preset length threshold is a preset critical value of the length of the link title corresponding to the first URL link. For example, the preset length threshold may be 35.
[0147] Step 306 , based on step 304 , according to the comparison result between the similarity and the preset similarity threshold, it is determined whether the target web page is a list page.
[0148] Step 307: When the comparison result shows that the similarity is greater than a preset similarity threshold, the target web page is determined to be a detailed page.
[0149] Step 308: When the comparison result shows that the similarity is less than a preset similarity threshold, it is determined that the target web page is a list page.
[0150] Step 309: Based on step 307, add the first URL link to the first link set.
[0151] The first link set is used to store URL links corresponding to detail pages.
[0152] Step 310: Based on step 308, the first URL link is added to the second link set.
[0153] The second link set is used to store URL links corresponding to list pages.
[0154] In one embodiment of the present application, in step 309 and step 310, the first URL link is added to the first link set and the first URL link is added to the second link set respectively. The URL link corresponding to the details page and the URL link corresponding to the list page can be saved in the database respectively, which can facilitate subsequent manual inspection and intervention.
[0155] Figure 4 It is a flowchart of a method for determining a list page according to another embodiment of the present application.
[0156] In order to more accurately determine whether the target web page corresponding to the first URL link is a list page, after adding the first URL link to the first link set, the method further includes:
[0157] Step 401: determine the median and mode of link lengths of URL links in a first link set.
[0158] In one embodiment of the present application, the median of the link lengths of the URL links in the first link set is the middle value of the link lengths of all the URL links in the first link set, and the mode of the link lengths of the URL links in the first link set is the value that appears most frequently in the link lengths of all the URL links in the first link set.
[0159] Step 402: If the link length of the first URL link is less than the mode and less than a specified value, the first URL link is removed from the first link set to the second link set.
[0160] In one embodiment of the present application, if the link length of the first URL link is less than the majority, that is, the link length of the first URL link is less than the link length of a part of the URL links in the first link set, it means that the first URL link is more likely to be the URL link corresponding to the list page.
[0161] In order to more accurately determine whether the target web page corresponding to the first URL link is a list page, the link length of the first URL link can be compared with the specified value. If the link length of the first URL link is still less than the specified value, it can be determined that the target web page corresponding to the first URL link is a list page, and the first URL link is removed from the first link set to the second link set.
[0162] It should be noted that the first URL link moved from the first link set to the second link set may be marked to distinguish it from the URL link originally existing in the second link set, and to facilitate manual inspection and intervention later.
[0163] In one embodiment of the present application, the specified value may be a value obtained by multiplying the median and a preset weight coefficient.
[0164] The preset weight coefficient is a preset coefficient value, for example, the preset weight coefficient may be 0.9.
[0165] The method for determining the list page in the embodiment of the present application improves the accuracy of determining that the target web page is a list page by secondary extraction of URL links and calculation of URL link similarity, URL link length and URL link title.
[0166] Another aspect of the present application provides a device for determining a list page.
[0167] Figure 5 is a structural block diagram of a device for determining a list page according to an embodiment of the present application. Figure 5 As shown, the list page determination device 50 may include: a first acquisition module 51, a second acquisition module 52, a first determination module 53, a second determination module 54 and a third determination module 55. Among them:
[0168] The first acquisition module 51 is used to acquire the current web page.
[0169] The second acquisition module 52 is used to acquire multiple first URL links in the current web page.
[0170] In one embodiment of the present application, when the number of jumps of the current web page is less than a preset jump threshold, the step of acquiring multiple first URL links in the current web page is performed.
[0171] The first determination module 53 is used to determine, for each first URL link, whether text content can be extracted from a target web page corresponding to the first URL link.
[0172] The second determination module 54 is used to determine the similarity between the first URL link and a second URL link in the first link set when the text content can be extracted from the target web page, wherein the second URL link is a URL link corresponding to the detail page.
[0173] The third determination module 55 is used to determine whether the target web page is a list page according to the comparison result between the similarity and a preset similarity threshold.
[0174] Specifically, when the comparison result is that the similarity is greater than a preset similarity threshold, the target web page is determined to be a detail page; when the comparison result is that the similarity is less than the preset similarity threshold, the target web page is determined to be a list page.
[0175] Figure 6 It is a structural block diagram of a device for determining a list page according to another embodiment of the present application.
[0176] like Figure 6 As shown, the list page determination device 60 may further include: a fourth determination module 66, a fifth determination module 67, a judgment module 68, a removal module 69, a first adding module 610 and a second adding module 611, wherein the first determination module 63 further includes: an acquisition unit 631 and a determination unit 632.
[0177] The fourth determining module 66 is used to determine the median and mode of the link lengths of the URL links in the first link set after the first URL link is added to the first link set.
[0178] The fifth determination module 67 is configured to determine that the target web page is a list page if no text content is extracted from the target web page and the length of the link title corresponding to the first URL link is less than a preset length threshold.
[0179] The judging module 68 is used to judge whether the jump times of the current web page are less than the preset jump times.
[0180] The removal module 69 is used to remove the first URL link from the first link set to the second link set when the link length of the first URL link is less than the mode and less than a specified value.
[0181] The first adding module 610 is used to add the first URL link to the first link set after determining that the target web page is a detailed page.
[0182] The second adding module 611 is used to add the first URL link to the second link set after determining that the target web page is a list page, wherein the second link set is used to store the URL link corresponding to the list page.
[0183] The acquisition unit 631 is used to acquire the hypertext markup language code of the target web page corresponding to the first URL link.
[0184] The determination unit 632 is used to determine whether the text content can be extracted from the target web page according to the hypertext markup language code.
[0185] The determining unit 632 is specifically used for:
[0186] Determine the document object model DOM tree corresponding to the current web page according to the hypertext markup language code, wherein each node in the DOM tree is a page tag in the current web page;
[0187] Get multiple paragraph nodes from the DOM tree, where the paragraph node is a node corresponding to the page tag paragraph P tag;
[0188] Determine the score corresponding to each paragraph node according to the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node;
[0189] Obtain the target paragraph node with the highest score from multiple paragraph nodes;
[0190] From the DOM tree, get the parent node corresponding to the target paragraph node;
[0191] It is determined whether the parent node is a text node, wherein if the parent node is a text node, it is determined that the text content can be extracted from the target web page.
[0192] The functions and specific implementation principles of the above modules in the embodiments of the present application can be referred to the above method embodiments and will not be repeated here.
[0193] The device for determining the list page of the embodiment of the present application obtains multiple first URL links in the current web page after obtaining the current web page; for each first URL link, determines whether the text content can be extracted from the target web page corresponding to the first URL link; in the case that the text content can be extracted from the target web page, determines the similarity between the first URL link and the second URL link in the first link set, wherein the second URL link is the URL link corresponding to the details page; and determines whether the target web page is a list page based on the comparison result of the similarity with the preset similarity threshold. Therefore, a method is proposed to determine whether the target web page corresponding to the corresponding URL link in the current web page is a list page by the similarity between the first URL link and the second URL link corresponding to the details page, so as to accurately determine whether the target web page corresponding to the URL link of the current web page is a list page.
[0194] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.
[0195] In order to implement the above embodiments, the present application also proposes 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 method described in the above method embodiments is implemented.
[0196] In order to implement the above embodiments, the present application also proposes a non-temporary computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the above method embodiments is implemented.
[0197] In order to implement the above embodiments, the present application also proposes a computer program product on which a computer program is stored. When the computer program is executed by a processor, the method described in the above method embodiments is implemented.
[0198] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present application. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0199] like Figure 7As shown, the electronic device 70 includes a processor 71, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 72 or a program loaded from a memory 76 to a random access memory (RAM) 73. Various programs and data required for the operation of the electronic device 70 are also stored in the RAM 73. The processor 71, the ROM 72, and the RAM 73 are connected to each other via a bus 74. An input / output (I / O) interface 75 is also connected to the bus 74.
[0200] The following components are connected to the I / O interface 75: a memory 76 including a hard disk, etc.; and a communication part 77 including a network interface card such as a LAN (Local Area Network) card, a modem, etc., and the communication part 77 performs communication processing via a network such as the Internet; a drive 78 is also connected to the I / O interface 75 as needed.
[0201] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 77. When the computer program is executed by the processor 71, the above-mentioned functions defined in the method of the present application are executed.
[0202] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 76 including instructions, and the above instructions can be executed by a processor 71 of an electronic device 70 to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0203] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0204] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0205] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0206] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0207] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0208] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0209] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0210] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for determining a list page, characterized in that: The method comprises: Get the current web page; Acquire multiple first URL links in the current web page; For each of the first URL links, determining whether text content can be extracted from a target web page corresponding to the first URL link; In the case that the text content can be extracted from the target web page, determining the similarity between the first URL link and a second URL link in the first link set, wherein the second URL link is a URL link corresponding to a detail page, wherein the first link set is used to store URL links corresponding to detail pages, and the first link set is a set of URL links corresponding to a preset detail page or a set of URL links corresponding to web pages from which the text content can be extracted; According to the comparison result between the similarity and a preset similarity threshold, it is determined whether the target web page is a list page.
2. The method according to claim 1, characterized in that in, The current web page is the home page of a specified website, or a page reached by a single click jump or multiple jumps to the home page. Before acquiring multiple first URL links in the current web page, the method further includes: Determine whether the jump number of the current web page is less than a preset jump number; The step of obtaining a plurality of first URL links in the current webpage includes: When the number of jumps of the current web page is less than a preset jump threshold, the step of acquiring a plurality of first URL links in the current web page is performed.
3. The method according to claim 1, characterized in that The determining whether the target web page is a list page according to the comparison result of the similarity with a preset similarity threshold comprises: If the comparison result shows that the similarity is greater than a preset similarity threshold, determining that the target web page is a detailed page; or, When the comparison result is that the similarity is less than or equal to a preset similarity threshold, it is determined that the target web page is a list page.
4. The method according to claim 3, characterized in that After determining that the target web page is a detailed page, the method further includes: Add the first URL link to the first link set.
5. The method according to claim 4, characterized in that After adding the first URL link to the first link set, the method further includes: Determine the median and mode of link lengths of URL links in the first link set; If the link length of the first URL link is less than the mode and less than a specified value, the first URL link is removed from the first link set to a second link set, wherein the second link set is used to store URL links corresponding to list pages, and the specified value is a value obtained by multiplying the median and a preset weight coefficient.
6. The method according to claim 1, characterized in that The method further comprises: If no text content is extracted from the target web page, and the length of the link title corresponding to the first URL link is less than a preset length threshold, it is determined that the target web page is a list page.
7. The method according to claim 3 or 6, characterized in that After determining that the target web page is a list page, the method further includes: The first URL link is added to a second link set, wherein the second link set is used to store URL links corresponding to list pages.
8. The method according to claim 1, characterized in that The step of determining whether text content can be extracted from the target webpage corresponding to the first URL link includes: Obtaining a hypertext markup language code of a target web page corresponding to the first URL link; According to the hypertext markup language code, it is determined whether text content can be extracted from the target web page.
9. The method according to claim 8, characterized in that The step of determining whether text content can be extracted from the target web page according to the hypertext markup language code includes: Determine, according to the hypertext markup language code, a document object model DOM tree corresponding to the current web page, wherein each node in the DOM tree is a page tag in the current web page; Obtain multiple paragraph nodes from the DOM tree, wherein the paragraph nodes are nodes corresponding to the paragraph P tag of the page; Determine the score corresponding to each paragraph node according to the word count information and the total number of punctuation marks in the paragraph text corresponding to each paragraph node; Acquire a target paragraph node with the highest score from the multiple paragraph nodes; From the DOM tree, obtain the parent node corresponding to the target paragraph node; It is determined whether the parent node is a text node, wherein if the parent node is a text node, it is determined that the text content can be extracted from the target web page.
10. A device for determining a list page, characterized in that: The device comprises: The first acquisition module is used to acquire the current web page; A second acquisition module, used to acquire multiple first URL links in the current web page; A first determination module, for determining, for each of the first URL links, whether text content can be extracted from a target web page corresponding to the first URL link; A second determination module is used to determine the similarity between the first URL link and a second URL link in the first link set when the text content can be extracted from the target web page, wherein the second URL link is a URL link corresponding to a detail page, wherein the first link set is used to store URL links corresponding to detail pages, and the first link set is a set of URL links corresponding to a preset detail page or a set of URL links corresponding to web pages from which the text content can be extracted; The third determination module is used to determine whether the target web page is a list page according to a comparison result between the similarity and a preset similarity threshold.
11. An electronic device, characterized in that: include: 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 method for determining a list page as described in any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for determining a list page as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Method of and system for collecting network data
US20140289394A1
System and method for automatically identifying classified websites
US8380693B1
