Data extraction method, device, electronic device and storage medium

By obtaining cell attribute information and element identification, finding and extracting data in HTML tables, the problem of not being able to determine the target table and extracting full table data in the existing technology is solved, and the accuracy and diversity of data extraction is achieved, satisfying the Data analysis requirements.

CN114491360BActive Publication Date: 2024-12-03BEIJING YUNCE INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111647593.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2024-12-03
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

In the prior art, the cell data given in HTML cannot effectively determine the target table and extract the full table data, resulting in difficulty in data extraction.

Method used

By obtaining the attribute information of the cell, determining the element identity of the target element, and looking up the target table based on the identity, thereby extracting multiple types of data.

Benefits of technology

It realizes the accurate determination of the target table based on cell attribute information and extracts rich and diverse data from it to meet the data analysis needs and improves the reliability and efficiency of data extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114491360B_ABST
    Figure CN114491360B_ABST
Patent Text Reader

Abstract

The present application discloses a data extraction method, device, electronic device and storage medium, including: obtaining a target element according to first attribute information of a first cell, wherein the first attribute information is obtained in response to a user's selection operation on the first cell in a specified page, the specified page is a page where the target element is located, based on the element identifier of the target element, searching for a target table corresponding to the target element in the specified page, and extracting multiple types of data from the target table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of Internet technology, and specifically relates to a data extraction method, device, electronic device and storage medium. Background Art

[0002] A table is defined by tags and consists of a header and a body. Each table has several rows, and each row is divided into several cells. Cells can contain text, pictures, lists, attributes, etc.

[0003] In some scenarios, Hypertext Markup Language (HTML) defines the meaning and structure of web page content. HTML uses elements to indicate text, images, and other content. For data in a given cell in HTML, there are many limitations in determining the corresponding target table in related technologies, and there are still problems such as being unable to determine the target table and extracting the full table data. Summary of the invention

[0004] The embodiments of the present application provide a data extraction method, device, electronic device and storage medium, which can solve the problem of being unable to determine the target table and extract the data of the entire table.

[0005] In a first aspect, an embodiment of the present application provides a data extraction method, comprising:

[0006] A target element is obtained according to first attribute information of a first cell, wherein the first attribute information is obtained in response to a user's selection operation on the first cell in a specified page, and the specified page is a page where the target element is located; based on an element identifier of the target element, a target table corresponding to the target element in the specified page is searched; and multiple types of data are extracted from the target table.

[0007] In a second aspect, an embodiment of the present application provides a data extraction device, including:

[0008] An acquisition module is used to acquire a target element based on first attribute information of a first cell, wherein the first attribute information is acquired in response to a user's selection operation on the first cell in a specified page, and the specified page is the page where the target element is located; a search module is used to search for a target table corresponding to the target element in the specified page based on an element identifier of the target element; and an extraction module is used to extract multiple types of data from the target table.

[0009] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0010] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0011] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.

[0012] In an embodiment of the present application, a target element is obtained according to the first attribute information of a first cell, wherein the first attribute information is obtained in response to a user selecting a first cell in a specified page, the specified page is the page where the target element is located, and based on the element identifier of the target element, a target table corresponding to the target element in the specified page is searched, and multiple types of data are extracted from the target table. Therefore, according to the attribute information of a given cell, the target table can be determined according to the element identifier of the target element corresponding to the attribute information, and multiple types of data can be extracted from the target table, and the data types are rich and can meet the needs of data analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 This is a first flow chart of the data extraction method provided in the embodiment of the present application;

[0014] Figure 2 It is a second flow chart of the data extraction method provided in the embodiment of the present application;

[0015] Figure 3 This is a third flow chart of the data extraction method provided in the embodiment of the present application;

[0016] Figure 4 This is a fourth flow chart of the data extraction method provided in the embodiment of the present application;

[0017] Figure 5 is a schematic diagram of the structure of a data extraction device provided in an embodiment of the present application;

[0018] Figure 6 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0020] In the following, in conjunction with the accompanying drawings, a data extraction method, device, electronic device and storage medium provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.

[0021] Figure 1 A data extraction method provided by an embodiment of the present invention is shown. The method can be executed by an electronic device, such as a terminal device. That is, the above data extraction method can be executed by hardware or software installed in the terminal device. The method includes the following steps:

[0022] Step S101: acquiring a target element according to first attribute information of a first cell, wherein the first attribute information is acquired in response to a user selecting the first cell in a specified page, and the specified page is a page where the target element is located.

[0023] Specifically, the designated page refers to the page where the target element corresponding to the first attribute information of the first cell is located, the first cell is at least one cell selected by the user in the designated page, and the selection operation may be to select an area including at least one cell, and the terminal device may respond to the selection operation and determine the cell in the area as the first cell. The first attribute information is the data in the first cell, and the data in the first cell has a corresponding marking element.

[0024] For example, the designated page may be a World Wide Web (Web) page, and the elements of a web page may include a menu bar, a link window, an input box, an icon, a button, a text box, text, a picture, a Web table, etc. Among them, a Web table is divided into a header and a body, and is identified by an element " ”、" "as well as" " form a table. Among them, "

[0025] "Used to define HTML tables and support HTML global attributes," "Used to define the table header, " " is used to define the table body. In Web tables, the element "<tr(table row)> "Used to define table rows, elements"<td(tabledata)> "Used to define cells, elements"<th(table header)> " is used to define the table header. In a Web table, the smallest content container is a cell, which is defined by the element " "Add the content to the cell, that is, the content of each cell should be written to the element" "; through the element" "Defines a table row. A row can contain multiple cells, for example, by using the element" "Create 4 cells and write elements" ", it means that a row consists of 4 cells; the element " " is used to define a header in a table, usually at the beginning of a row or column.

[0026] More specifically, the data types in the cell include but are not limited to at least one of an identifier (Identity document, ID), a name (Name), a tag (Tag), an extensible markup language path (Xpath), text (Text), a style (ClassName), a link (Link), a position (rect), and internal elements (children), where the internal elements (children) are child elements, such as at least one of a layer tag (div), a label tag (label), and an inline tag (span).

[0027] The ID specifies the unique identifier of the element; the Name specifies the name of the element; the ClassName specifies the type of the element; the Extensible Markup Language Path (Xpath) can be used to detect whether a node in a document matches a pattern. XPath provides a wealth of functions that can flexibly support multiple attribute matching and is a positioning feature value obtained based on the attributes of the element; the Tag specifies the tag content of the element; the Link specifies the link address of the element; and the Text specifies the text inside the element.

[0028] It is worth noting that the web page can be a page of a web application opened on a browser, wherein the browser can be Google Chrome, Web Pathfinder, Internet Explorer , IE) browser, Firefox browser, etc.

[0029] Step S103: based on the element identifier of the target element, searching for a target table corresponding to the target element in the specified page.

[0030] Specifically, an element carries a tag to determine the type of the current element.

[0031] Step S105: extracting multiple types of data from the target table.

[0032] Specifically, extracting multiple types of data from the target table includes extracting at least one row or at least one column of data from the target table, that is, the entire table of data can be extracted from the target table, or one to multiple columns or one to multiple rows of data can be extracted from the target table. For the type of data, it can include but is not limited to: identification number (ID), name (Name), style (ClassName), extensible markup language path (Xpath), tag (Tag), link (Link) and text (Text). It is worth noting that the type of data can also be other types of data, which is not limited in the embodiments of the present application.

[0033] The data extraction method provided by the embodiment of the present invention can determine the target table according to the attribute information of a given cell and the element identifier of the target element corresponding to the attribute information, and extract multiple types of data from the target table. The data types are rich and can meet data analysis needs.

[0034] In one implementation, the first attribute information includes at least one of an identifier (ID), a tag (Tag), an extensible markup language path (Xpath), and text (Text), and obtaining the target element according to the first attribute information of the first cell includes one of the following steps: obtaining the target element according to the identifier (ID); when the browser where the specified page is located is an IE browser, obtaining the target element according to the combination information of the tag Tag and the text Text; when the browser where the specified page is located is not the IE browser, obtaining the target element according to the extensible markup language path Xpath, or obtaining the target element according to the combination information of the tag Tag and the text Text.

[0035] Specifically, according to the combination information of the tag Tag and the text Text, obtaining the target element includes: obtaining the elements composed of multiple tags (Tags) and text Text in the specified page, and taking the element composed of the tag (Tag) and text Text that is ranked first as the target element, wherein the elements composed of multiple tags (Tags) and text Text can be sorted according to the marking time and type priority. Of course, there are other ways to select the target element, which are not limited to the embodiments of the present application.

[0036] More specifically, when the first attribute information includes one of an identifier (ID), a tag (Tag), an extensible markup language path (Xpath), and a text (Text), the above steps can be applied accordingly to obtain the target element. When the first attribute information includes at least two of the identifier (ID), the tag (Tag), the extensible markup language path (Xpath), and the text (Text), the priority of the attribute information is set to determine which step to use first to obtain the target element. For example, the priorities of the identifier (ID), the tag (Tag), the extensible markup language path (Xpath), and the text (Text) are set from high to low in the order of identifier (ID), tag (Tag), extensible markup language path (Xpath), and text (Text). When the first attribute information includes four pieces of information, the identifier (ID), the tag (Tag), the extensible markup language path (Xpath), and the text (Text) are used first to obtain the target element. element; if the first attribute information includes three information of tag (Tag), extensible markup language path (Xpath), and text (Text), when it is determined that the first attribute information does not contain an identifier (ID), if the browser where the specified page is located is an IE browser, the target element is obtained based on the combination information of the tag Tag and the text Text first, and if the browser where the specified page is located is not the IE browser, the target element is obtained based on the extensible markup language path Xpath first, and if the first attribute information does not include the extensible markup language path (Xpath), the target element is obtained based on the combination information of the tag Tag and the text Text. In this way, the target element is obtained by multiple methods with high reliability, thereby further improving the reliability of extracting data from the target table.

[0037] In another possible implementation, when the first attribute information includes at least two of an identifier (ID), a tag (Tag), an extensible markup language path (Xpath), and a text (Text), if the step corresponding to the attribute information with a higher priority fails to obtain the target element, the step corresponding to the attribute information with a lower priority can be used to obtain the target element. For example, when the first attribute information includes an identifier (ID), a tag (Tag), an extensible markup language path (Xpath), and a text (Text), if the target element fails to be obtained according to the identifier (ID), when the browser where the specified page is located is an IE browser, the step of "obtaining the target element according to the combined information of the tag Tag and the text Text" is used, and so on. In this way, the target element can be obtained by multiple methods, and when one of the methods fails to obtain the target element, the target element can be obtained again by the remaining methods, which has high reliability, thereby further improving the reliability of extracting data from the target table.

[0038] In one possible implementation, Figure 2 As shown, based on the element identifier of the target element, searching for the target table corresponding to the target element in the specified page includes the following steps:

[0039] Step S1031: when the element identifier is the first table tag, find out whether the first table tag contains at least one of a table header (thead) and a table body (tbody).

[0040] Step S1032: When the first table tag includes at least one of the table header (thead) and the table body (tbody), determine the target table according to at least one of the table header (thead) and the table body (tbody); when the first table tag does not include at least one of the table header (thead) and the table body (tbody), determine that the target table corresponding to the element identifier is an empty table.

[0041] Specifically, when the first table tag includes a table header (thead) and a table body (tbody), the target table is determined by the combination of the table header (thead) and the table body (tbody), that is, the table composed of the table header (thead) and the table body (tbody) is the target table that the terminal device needs to find.

[0042] When the first table tag contains a table header (thead), the third table tag is searched downward at the same level as the target element according to the page structure of the specified page, the table body (tbody) is determined according to the third table tag, and the target table is determined by the combination of the table header (thead) and the table body (tbody).

[0043] Specifically, when the first table tag contains a table header (thead) but not a table body (tbody), the next table tag (the third table tag) is searched downwards according to the editing logic at the same nesting level where the target element is located. If the next table tag is found, then if the table tag contains the next table body (the first table body), the next table body is determined to be the table body (tbody) of the target element. If the third table tag only contains a table header (the first table header) but not a table body, the first table header is determined to be the table body (tbody) of the target element. After the table header (thead) and the table body (tbody) are found, the table consisting of the table header (thead) and the table body (tbody) is used as the target table.

[0044] When the first table tag contains a table body (tbody), the fourth table tag is searched upward at the same level of the target element according to the page structure of the specified page, the table header (thead) is determined according to the fourth table tag, and the target table is determined by the combination of the table header (thead) and the table body (tbody).

[0045] Specifically, when the first table tag contains only the table body (tbody) but not the table header (thead), the next table tag (the fourth table tag) is searched upwards in the same nested layer where the table body (tbody) is located according to the programming logic. When the fourth table tag contains the second table header, the second table header is determined to be the table header (thead). When the fourth table tag contains only the table body (the second table body) but not the table header, the second table body is determined to be the table header (thead). The table consisting of the obtained table header (thead) and table body (tbody) is used as the target table.

[0046] Step S1033: When the element identifier is not the first table tag, obtain the parent node element at the upper level of the target element according to the page structure of the specified page; when the element identifier of the parent node element is the second table tag, find out whether the second table tag contains at least one of the table header (thead) and the table body (tbody).

[0047] Specifically, if the element identifier is not a table tag, the parent node element is searched in the nested layer of the target element. If the parent node element is a table tag, the target table is determined according to the table tag. If the parent node element is not the second table tag, and the parent node is not the root node, the loop continues to get the next parent node from the parent node's previous level until the next table tag is obtained or the parent node is the root node, and the loop ends.

[0048] Step S1034: When the second table tag includes at least one of the table header (thead) and the table body (tbody), determine the target table according to at least one of the table header (thead) and the table body (tbody); when the second table tag does not include at least one of the table header (thead) and the table body (tbody), determine that the target table corresponding to the element identifier is an empty table.

[0049] Specifically, in the case where the second table tag includes at least one of the table header (thead) and the table body (tbody), determining the target table according to at least one of the table header (thead) and the table body (tbody) can be cross-referenced with the above-mentioned first table tag "in the case where at least one of the table header (thead) and the table body (tbody) is included, determining the target table according to at least one of the table header (thead) and the table body (tbody), and the embodiments of the present application will not be repeated here.

[0050] The technical solution provided in the embodiment of the present application can obtain the target table more reliably by cyclically searching for the table tag, and the header (thead) and the table body (tbody) in the table tag to obtain the target table, thereby extracting the data in the target table.

[0051] Figure 3 A data extraction method provided by an embodiment of the present invention is shown. The method can be executed by an electronic device, such as a terminal device. That is, the above data extraction method can be executed by hardware or software installed in the terminal device. The method includes the following steps:

[0052] Step S301: Acquire a target element according to first attribute information of a first cell, wherein the first attribute information is acquired in response to a user selecting the first cell in a specified page, and the specified page is the page where the target element is located.

[0053] Step S302: when the target element fails to be obtained, the target element is obtained by using the second attribute information given by the iframe element of the specified page.

[0054] Specifically, the iframe element is HTML The tag acts as a document in a document. The iframe element creates an inline frame (i.e., an inline frame) containing another document. When the target element cannot be obtained through the first attribute information, the iframe element gives the second attribute information of the second cell associated with the first cell, and then obtains the target element. The second attribute information includes at least one of an identifier ID, a tag Tag, an extensible markup language path Xpath, a text Text, a style ClassName, a link Link, and a position rect.

[0055] Step S303: based on the element identifier of the target element, searching for the target table corresponding to the target element in the specified page.

[0056] After successfully acquiring the target element according to the second attribute information, the target table is searched according to the element identifier of the target element acquired according to the second attribute information. The search for the target table according to the element identifier of the target element acquired according to the second attribute information can be referenced with the above embodiment, and the embodiment of the present application is not repeated here.

[0057] Step 305: Extract multiple types of data from the target table.

[0058] It is worth noting that step S301, step S304 and step S305 in the embodiment of the present application have the same or similar implementation methods as the above-mentioned embodiment, which can refer to each other, and the embodiment of the present application will not be repeated here.

[0059] A data extraction method provided by an embodiment of the present invention can obtain the target element according to the second attribute information when the target element cannot be obtained according to the first attribute information, thereby further improving the reliability of obtaining the target table.

[0060] For example, the following is combined Figure 4 , an embodiment of the present application is described, and the embodiment includes the following steps:

[0061] Step S401: Acquire first attribute information of a first cell in a specified page.

[0062] Specifically, when the user selects the first cell, the terminal device can obtain the first attribute information of the first cell. The first attribute information can refer to the description of the above embodiment, and the embodiment of the present application will not be repeated here.

[0063] Step S402: Is there an identification (ID) in the first attribute information? If yes, proceed to step S403; if not, proceed to step S404.

[0064] Step S403: Acquire the target element according to the identifier (ID).

[0065] Step S404: Is it an IE browser? If yes, proceed to step S405; if no, proceed to step S406.

[0066] Step S405: Obtain the target element according to the combination information of the tag Tag and the text Text.

[0067] Step S406: Whether there is an extensible markup language path (Xpath) in the first attribute information, if yes, proceed to step S407, if not, proceed to step S408.

[0068] Step S407: Acquire the target element according to the Extensible Markup Language path (Xpath).

[0069] Step S408: Acquire the target element by forming an Xpath based on the tag Tag and the text Text.

[0070] Step S409: Whether the target element is obtained, if yes, proceed to step S410, if not, proceed to step S411.

[0071] Step S410: Whether the target element is the first table tag, if yes, proceed to step S412, if no, proceed to step S413.

[0072] Step S411: Acquire the target element through the second attribute information given by the iframe element of the specified page. If the target element is acquired, proceed to step S410. If the target element is not acquired, end.

[0073] Step S412: Whether the target element contains a table header (thead) and a table body (tbody), if not, proceed to step S417, if yes, proceed to step S418.

[0074] Step S413: Obtain the parent node element from the previous level of the target element.

[0075] Wherein, obtaining the parent node element at the upper level of the target element means looping upward from the target element to search for the parent node element until the parent node element is the root node and the loop ends or the loop ends when the parent node element is found.

[0076] Step S414: Whether the parent node element is the second table tag, if yes, proceed to step S412, if no, proceed to step S416.

[0077] Step S416: Whether the parent node is a root node, if yes, then end, if not, then go to S413.

[0078] Step S417: Whether the target element contains only thead, if yes, proceed to step S419, if no, proceed to step S420.

[0079] Step S418: The target table is composed of the table header (thead) and the table body (tbody), and data is extracted from the target table and the process ends.

[0080] Step S419: Search for the third table tag at the same level as the target element.

[0081] Step S420: Whether the target element contains only the table body (tbody), if so, proceed to step S421, if not, proceed to step S422.

[0082] Step S421: Search upward for the fourth table tag at the same level as the target element.

[0083] Step S422: The table is empty and the process ends.

[0084] Step S423: Check whether both the table header (thead) and the table body (tbody) are present. If so, proceed to step S418. If not, proceed to step S424 and step S425.

[0085] That is to say, if the third table tag contains a table body and the fourth table tag contains a table header, the table body in the third table tag is used as the table body (tbody) and the table header in the fourth table tag is used as the table header (thead).

[0086] Step S424: If there is only a table header (thead), then search the table upwards again. If found, use the data in the table as the new table header, use the original table header (thead) as the table body, and go to step S418.

[0087] If the table is not found, the table header (thead) is directly returned as table data.

[0088] Step S425: If there is only a table body (tbody), search the table downwards again. If the data in the table is found, use it as a new table body, use the original table body (tbody) as the table header, and go to step S418.

[0089] If the table is not found, the table body (tbody) is directly returned as table data.

[0090] Through the technical solution provided by the embodiment of the present application, the target table can be determined according to the attribute information of a given cell and the element identifier of the target element corresponding to the attribute information, and multiple types of data can be extracted from the target table. The data types are rich and can meet the needs of data analysis. In addition, the target element is obtained by multiple methods. If one of the methods fails to obtain the target element, the target element can be obtained again by the remaining methods, which has high reliability, thereby further improving the reliability of extracting data from the target table. Further, by looping to find the table tag, and the header (thead) and body (tbody) in the table tag to obtain the target table, the target table can be obtained more reliably, thereby extracting the data in the target table. Finally, in the case where the target element cannot be obtained according to the first attribute information, the target element can be obtained again according to the second attribute information, thereby further improving the reliability of obtaining the target table.

[0091] It should be noted that the data extraction method provided in the embodiment of the present application can be executed by a data extraction device or a control module in the data extraction device for executing the data extraction method. In the embodiment of the present application, the data extraction device provided in the embodiment of the present application is illustrated by taking the data extraction method executed by the data extraction device as an example.

[0092] Figure 5 Schematic diagram of a data extraction device according to an embodiment of the present invention. Figure 5 As shown, the data extraction device 500 includes:

[0093] An acquisition module 501 is used to acquire a target element according to first attribute information of a first cell, wherein the first attribute information is acquired in response to a user's selection operation on the first cell in a specified page, and the specified page is a page where the target element is located; a search module 502 is used to search for a target table corresponding to the target element in a specified page based on an element identifier of the target element; an extraction module 503 is used to extract multiple types of data from the target table.

[0094] Through the technical solution disclosed in the embodiment of the present application, the target table can be determined according to the attribute information of a given cell and the element identifier of the target element corresponding to the attribute information, and multiple types of data can be extracted from the target table. The data types are rich and can meet data analysis needs.

[0095] In a possible implementation, the first attribute information includes at least one of an identification ID, a tag Tag, an extensible markup language path Xpath and a text Text, and the acquisition module 501 is further used to implement one of the following: acquiring a target element according to the identification ID; when the browser where the specified page is located is an IE browser, acquiring the target element according to the combination information of the tag Tag and the text Text; when the browser where the specified page is located is not the IE browser, acquiring the target element according to the extensible markup language path Xpath, or acquiring the target element according to the combination information of the tag Tag and the text Text.

[0096] In a possible implementation, the acquisition module 501 is further configured to acquire the target element by using the second attribute information given by the iframe element of the specified page when the acquisition of the target element fails.

[0097] In a possible implementation, the search module 502 is further configured to, when the element identifier is a first table tag, search whether the first table tag includes at least one of a table header (thead) and a table body (tbody);

[0098] In the case where the first table tag includes at least one of the table header (thead) and the table body (tbody), the target table is determined according to at least one of the table header (thead) and the table body (tbody); in the case where the first table tag does not include at least one of the table header (thead) and the table body (tbody), it is determined that the target table corresponding to the element identifier is an empty table; in the case where the element identifier is not the first table tag, the parent node element is obtained from the upper level of the target element according to the page structure of the specified page; in the case where the element identifier of the parent node element is the second table tag, it is found whether the second table tag includes at least one of the table header (thead) and the table body (tbody); in the case where the second table tag includes at least one of the table header (thead) and the table body (tbody), the target table is determined according to at least one of the table header (thead) and the table body (tbody); in the case where the second table tag does not include at least one of the table header (thead) and the table body (tbody), it is determined that the target table corresponding to the element identifier is an empty table.

[0099] In a possible implementation, the search module 502 is further used to determine the target table through a combination of the table header (thead) and the table body (tbody) when the first table tag or the second table tag includes a table header (thead) and a table body (tbody); when the first table tag or the second table tag includes a table header (thead), search downward for a third table tag at the same level as the target element according to the page structure of the specified page, determine the table body (tbody) according to the third table tag, and determine the target table through a combination of the table header (thead) and the table body (tbody); when the first table tag or the second table tag includes a table body (tbody), search upward for a fourth table tag at the same level as the target element according to the page structure of the specified page, determine the table header (thead) according to the fourth table tag, and determine the target table through a combination of the table header (thead) and the table body (tbody).

[0100] In a possible implementation, the search module 502 is further configured to determine that the first table body is a table body (tbody) when the third table tag includes the first table body, and to determine that the first table header is a table body (tbody) when the third table tag includes the first table header.

[0101] In a possible implementation, the search module 502 is further configured to determine that the second table header is a table header (thead) when the fourth table tag includes a second table header, and to determine that the second table body is a table header (thead) when the fourth table tag includes a second table body.

[0102] In a possible implementation, the extraction module 503 is further used to extract at least one row or at least one column of data in the target table, where the data includes at least one of the following: an identifier ID, a tag Tag, an extensible markup language path Xpath, a text Text, a style ClassName, a link Link, and a position rect.

[0103] The data extraction device 500 in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a palmtop computer, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0104] The data extraction device 500 in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0105] The data extraction device 500 provided in the embodiment of the present application can achieve Figures 1 to 4 To avoid repetition, the various processes implemented in the method embodiment are not described here.

[0106] Optional, such as Figure 6 As shown, an embodiment of the present application also provides an electronic device 600, including a processor 602, a memory 601, and a program or instruction stored in the memory 601 and executable on the processor 602. When the program or instruction is executed by the processor 602, each process of the above-mentioned data extraction method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0107] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.

[0108] This embodiment can implement each process of the above-mentioned data extraction method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0109] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned data extraction method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0110] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0111] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned data extraction method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0112] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0113] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0115] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A data extraction method, characterized in that: include: Acquire a target element according to first attribute information of a first cell, wherein the first attribute information is acquired in response to a user selecting the first cell in a specified page, and the specified page is a page where the target element is located; Based on the element identifier of the target element, searching for a target table corresponding to the target element in the specified page; extracting multiple types of data from the target table; Wherein, searching the target table corresponding to the target element in the specified page based on the element identifier of the target element includes: In the case where the element identifier is the first table tag, searching whether the first table tag includes at least one of a table header thead and a table body tbody; In a case where the first table tag includes at least one of a table header thead and a table body tbody, determining the target table according to at least one of the table header thead and the table body tbody; In a case where the first table tag does not include at least one of a table header thead and a table body tbody, determining that the target table corresponding to the element identifier is an empty table; When the element identifier is not the first table tag, obtaining a parent node element from an upper level of the target element according to the page structure of the designated page; In a case where the element identifier of the parent node element is a second table tag, searching whether the second table tag includes at least one of a table header thead and a table body tbody; In a case where the second table tag includes at least one of a table header thead and a table body tbody, determining the target table according to at least one of the table header thead and the table body tbody; When the second table tag does not include at least one of a table header thead and a table body tbody, it is determined that the target table corresponding to the element identifier is an empty table.

2. The data extraction method according to claim 1, characterized in that: The first attribute information includes at least one of an identifier ID, a tag Tag, an extensible markup language path Xpath, and a text Text, and acquiring a target element according to the first attribute information of the first cell includes one of the following: According to the identification ID, obtain the target element; When the browser where the designated page is located is IE browser, acquiring the target element according to the combination information of the tag Tag and the text Text; In the case that the browser where the designated page is located is not the IE browser, the target element is acquired according to the extensible markup language path Xpath, or the target element is acquired according to the combination information of the tag Tag and the text Text.

3. The data extraction method according to claim 1, characterized in that: After acquiring the target element according to the first attribute information of the first cell, the method further includes: In the case where the target element fails to be obtained, the target element is obtained through the second attribute information given by the iframe element of the designated page.

4. The data extraction method according to claim 1, characterized in that: The determining the target table according to at least one of the table header thead and the table body tbody comprises: In the case where the first table tag or the second table tag includes a table header thead and a table body tbody, the target table is determined by a combination of the table header thead and the table body tbody; In the case that the first table tag or the second table tag includes a table header thead, searching for a third table tag at the same level of the target element according to the page structure of the specified page, determining a table body tbody according to the third table tag, and determining the target table by combining the table header thead and the table body tbody; When the first table tag or the second table tag contains a table body tbody, the fourth table tag is searched upward at the same level of the target element according to the page structure of the specified page, the table header thead is determined according to the fourth table tag, and the target table is determined by the combination of the table header thead and the table body tbody.

5. The data extraction method according to claim 4, characterized in that: Determining the table body tbody according to the third table tag includes: When the third table tag includes a first table body, the first table body is determined to be the table body tbody; and when the third table tag includes a first table header, the first table header is determined to be the table body tbody; Determining the table header thead according to the fourth table tag includes: When the fourth table tag includes a second table header, the second table header is determined to be the table header thead; and when the fourth table tag includes a second table body, the second table body is determined to be the table header thead.

6. The data extraction method according to claim 1, characterized in that: The extracting multiple types of data from the target table comprises: At least one row or at least one column of data in the target table is extracted, and the types of the data include: ID, Tag, Extensible Markup Language path Xpath, Text, ClassName, Link and Rect.

7. A data extraction device, characterized in that: include: an acquisition module, configured to acquire a target element according to first attribute information of a first cell, wherein the first attribute information is acquired in response to a user selecting the first cell in a specified page, and the specified page is a page where the target element is located; A search module, used for searching a target table corresponding to the target element in the specified page based on the element identifier of the target element; An extraction module, used for extracting multiple types of data from the target table; The search module is further used to search whether the first table tag contains at least one of a table header thead and a table body tbody when the element identifier is the first table tag; When the first table tag contains at least one of the table header thead and the table body tbody, the target table is determined according to at least one of the table header thead and the table body tbody; when the first table tag does not contain at least one of the table header thead and the table body tbody, the target table corresponding to the element identifier is determined to be an empty table; when the element identifier is not the first table tag, the parent node element is obtained from the upper level of the target element according to the page structure of the specified page; when the element identifier of the parent node element is the second table tag, it is searched whether the second table tag contains at least one of the table header thead and the table body tbody; when the second table tag contains at least one of the table header thead and the table body tbody, the target table is determined according to at least one of the table header thead and the table body tbody; when the second table tag does not contain at least one of the table header thead and the table body tbody, the target table corresponding to the element identifier is determined to be an empty table.

8. An electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method according to any one of claims 1 to 6.

9. A readable storage medium storing a program or instruction, wherein the program or instruction, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.