A method and device for converting to a universal API interface for interaction

By entering the application and generating a general API interface, the problem of data sharing between H5 pages and API interfaces is solved, and multi-terminal data sharing is realized, which simplifies the data acquisition process and improves the efficiency of data resource utilization.

CN118779554BActive Publication Date: 2025-02-28INSPUR SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411266865.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2025-02-28
Estimated Expiration
2044-09-11

AI Technical Summary

Technical Problem

The prior art is difficult to convert H5 pages or interface data into general interfaces, resulting in limited data sharing and the inability to realize multi-terminal data sharing.

Method used

By entering the application, determine the type of resource that needs to be shared. If it is an H5 page, access the source code through the browser to find the element and interface, and enter element information; if it is an API interface, enter the basic information and parameters of the interface, and the backend calls the interface through the tool class to generate a general API interface.

Benefits of technology

It realizes the rapid display and sharing of H5 pages and API interface data, simplifies the data acquisition process, optimizes the utilization of data resources, provides convenient and efficient data interaction methods, and improves the value and utilization efficiency of data resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present invention relates to the field of Internet technology, and specifically provides a method and device for converting to a general API interface for interaction, the steps are as follows: S1, input application according to shared resources; S2, determine whether the resource to be shared is an H5 page or an API interface; S3, if the resource is an H5 page, the browser accesses the H5 page link, and finds the elements to be shared and the interface to be used by viewing the source code; S4, if the resource is an API interface, the front end inputs the first page as the homepage of the application; S5, inputs button information in the first page, and the goto field of the button inputs the page code of the second page; S6, the third party realizes the display of the result page according to the page information and button information returned by the general interface. Compared with the prior art, the present invention can realize multi-terminal data sharing, and further improves the value and utilization efficiency of data resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and specifically provides a method and device for converting into a universal API interface for interaction. Background Art

[0002] A method and device for configuring page crawling rules in an existing patent relate to the field of computer technology. The main purpose is to automatically generate page crawling rules and improve the generation speed of crawling rules. The main technical scheme is: select a page element to be crawled from a page that needs to configure crawling rules; generate path information of the page element according to the attribute information corresponding to the page element to be crawled; generate a regular expression that matches the content of the page element to be crawled by setting a regular expression template that matches the page element to be crawled; configure the page crawling rules of the page to be crawled according to the display rules of the page element to be crawled in the page to be crawled and the position information of the page element to be crawled in the page to be crawled.

[0003] Another existing patent is a data sharing method that implements set protocol conversion in an API manner, including the steps of: API service entry; wherein the entry method at least includes: quickly importing RESTful through a Swagger document, or quickly importing a WebService through a WSDL document, or manually entering an API service; determining the service type to which the entered API service belongs, and converting the corresponding API service interface information format from a second format that is not the first format to a first format; wherein the first format is a RESTful format, and the second format is a format other than the first format; performing service joint debugging on the API service after the interface information format is converted to ensure that the service can be called normally after it is officially released; wherein the service joint debugging method at least includes associating plug-ins and custom proxy addresses; performing joint debugging tests after service joint debugging, and releasing the service after the test passes.

[0004] In the prior art, how to convert H5 page or interface data into a universal interface and realize data sharing through technical means, thereby eliminating data sharing barriers caused by network or hardware problems and realizing the possibility of multi-terminal data sharing, is an urgent problem to be solved by technical personnel in this field. Summary of the invention

[0005] The present invention aims at the above-mentioned deficiencies of the prior art and provides a method for converting into a universal API interface for interaction with high practicality.

[0006] A further technical task of the present invention is to provide a device that is reasonably designed, safe and applicable and is converted into a universal API interface for interaction.

[0007] The technical solution adopted by the present invention to solve its technical problem is:

[0008] A method for converting to a general API interface for interaction, the steps are as follows:

[0009] S1. Enter the application based on the shared resources;

[0010] S2. Determine whether the resource to be shared is an H5 page or an API interface;

[0011] S3. If the resource is an H5 page converted into a general API interface, the operation is as follows:

[0012] Use a browser to access the H5 page link and find the elements that need to be shared and the interfaces used by viewing the source code;

[0013] Refer to the shared H5 page to enter a page on the front end, and enter the element information to be displayed in the entered page;

[0014] The element information includes attribute name, attribute type, associated ID, default value, prompt information, attribute length, validation rule, selector, sorting, whether required, whether read-only, whether crawling, whether enabled, whether passing data, whether obtaining data and remarks;

[0015] When entering the element information to be displayed in the entered page, it further includes:

[0016] (1) If the value of a page element is a fixed value, fill it in the default field and the backend will return the default value as the value;

[0017] (2) If the value of the element is crawled through a shared H5 page, enter the crawling expression, and the backend will crawl the corresponding content of the H5 page through the relevant methods of JSOUP and return it as the value;

[0018] (3) If the value of the element is obtained through an API interface, you need to enter the basic information of the API interface first, and then enter the corresponding interface ID in the field. The backend will find the corresponding interface information through the associated ID, call the interface through the Hutool tool class, and return the return result of the interface as the value;

[0019] If the resource is an API interface converted to a general API interface, the operation is as follows:

[0020] The front end enters the first page as the home page of the application. According to the parameters required by the interface, the corresponding page element information is added to the entered page. The element information needs to enter whether to pass the data identifier. The third party determines whether to pass it as a parameter when calling the next page based on the field information;

[0021] The front end enters the second page as the result page of the application. According to the result returned by the interface, the corresponding page element information is added to the result page entered in the previous step. The back end obtains the interface return value through the tool class of Hutool, and implements the parsing of the interface result through the configured parsing method name and the reflection mechanism of Java, and assigns the final result to the value attribute of the element.

[0022] Enter the button information in the first page, and enter the page code of the second page in the button's goto field;

[0023] S4. The third party displays the result page based on the page information and button information returned by the general interface.

[0024] Furthermore, in step S4, the third party parses the page information and button information returned by the universal interface into its own page according to the standard, clicks the button to trigger the universal interface again, parses the data into the second page according to the standard, and displays the result page.

[0025] A device for converting to a universal API interface for interaction, comprising: at least one memory and at least one processor;

[0026] The at least one memory is used to store a machine-readable program;

[0027] The at least one processor is used to call the machine-readable program to execute a method of converting to a universal API interface for interaction.

[0028] Compared with the prior art, the method and device for converting to a universal API interface for interaction of the present invention has the following outstanding beneficial effects:

[0029] The present invention simplifies the process of data display, reduces the complexity of obtaining information, and effectively optimizes the use of data resources. It not only realizes the rapid display and sharing of H5 page and API interface data, but also provides a more convenient and efficient data interaction method for all parties, realizes multi-terminal data sharing, and further improves the value and utilization efficiency of data resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0031] Attached Figure 1 It is a method of converting application information into a common API interface for interaction.

[0032] Attached Figure 2 It is a schematic diagram of the backend processing flow in a method of converting to a general API interface for interaction;

[0033] Attached Figure 3 It is a diagram of the third-party call process in a method that is converted into a general API interface for interaction. DETAILED DESCRIPTION

[0034] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] A best embodiment is given below:

[0036] like Figure 1-3 As shown, a method of converting into a general API interface for interaction in this embodiment fixes the content returned by the general interface into a Json structure, and the structure includes a set of HTML tags, a set of HTML buttons, and key-value pairs of basic information descriptions. The third party parses the label and button information of the interface according to the rules through the return results of the interface, and then displays it on its own page to achieve resource sharing.

[0037] To implement this process, you need to first enter the content that the H5 page needs to display into the system through the front-end system, such as element information and button information. The back-end code determines whether the entered element tag attribute is crawled. If it is crawled, the Document object is obtained through the corresponding method of JSOUP according to the path configured on the page.

[0038] Then, the Document is parsed according to the configured expression, and the value is assigned to the value attribute of the field to complete the assignment of the field attribute; if the element tag attribute is not crawled, a default value is given for the fixed value, and for the value obtained by the interface, the background uses the interface template configured in the front end and the Hutool tool class to implement the interface call. According to the configured parsing method name, the interface result is parsed through Java's reflection mechanism, and the final result is assigned to the value attribute of the element.

[0039] Finally, all element information is returned, and the data sharing of H5 pages or interfaces can be realized through a common interface.

[0040] The specific steps are as follows:

[0041] S1. Enter the application based on the shared resources (refer to Figure 1 Application Information Table);

[0042] S2. Determine whether the resource to be shared is an H5 page or an API interface;

[0043] S3. If the resource is an H5 page converted into a general API interface;

[0044] Further including:

[0045] S3-1. Use the browser to access the H5 page link and find the elements to be shared and the interfaces to be used by viewing the source code.

[0046] S3-2. Refer to the shared H5 page and enter a page on the front end (reference Figure 1 Page basic information table);

[0047] S3-3. Refer to the shared H5 page and enter the element information to be displayed in the page entered in the previous step (reference Figure 1 Page element information table);

[0048] (1) If the value of a page element is a fixed value, fill it in the default field and the backend will return the default value as the value;

[0049] (2) If the value of the element is crawled through a shared H5 page, enter the crawling expression, and the backend will crawl the corresponding content of the H5 page through the relevant methods of JSOUP and return it as the value;

[0050] (3) If the value of an element is obtained through an interface, you need to first enter the basic information of the interface, including the interface address, request method, interface parameters, parameter passing method, etc., and then enter the corresponding interface ID in the field. The backend will find the corresponding interface information through the associated ID, call the interface through the Hutool tool class, and return the return result of the interface as the value.

[0051] If the resource is an API interface converted to a general API interface, the front end enters the first page as the homepage of the application;

[0052] include:

[0053] (1) The front end enters the first page as the homepage of the application;

[0054] (2) According to the parameters required by the interface, add the corresponding page element information to the page entered in the previous step. The element information here needs to enter whether to pass the data identifier. The third party determines whether to pass it as a parameter when calling the next page based on the field information;

[0055] (3) The front end enters the second page as the result page of the application;

[0056] (4) According to the result returned by the interface, the corresponding page element information is added to the result page entered in the previous step. The backend obtains the interface return value through the Hutool tool class, and implements the interface result parsing through the configured parsing method name and Java's reflection mechanism, and assigns the final result to the value attribute of the element.

[0057] Enter the button information in the first page, and enter the page code of the second page in the button's goto field;

[0058] S4. The third party displays the result page according to the page information and button information returned by the general interface;

[0059] The third party parses the page information and button information returned by the general interface into its own page according to the standard. After clicking the button, the general interface is called again, and the data is parsed into the second page according to the standard to display the result page.

[0060] Based on the above method, a device for converting into a universal API interface for interaction in this embodiment includes: at least one memory and at least one processor;

[0061] The at least one memory is used to store a machine-readable program;

[0062] The at least one processor is used to call the machine-readable program to execute a method of converting into a universal API interface for interaction.

[0063] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementations. Any technical solutions that comply with the claims of the present invention and any appropriate changes or substitutions made by ordinary technicians in the relevant technical field shall fall within the patent protection scope of the present invention.

[0064] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for converting to a general API interface for interaction, characterized in that: The steps are as follows: S1. Enter the application based on the shared resources; S2. Determine whether the resource to be shared is an H5 page or an API interface; S3. If the resource is an H5 page converted into a general API interface, the operation is as follows: Use a browser to access the H5 page link and find the elements that need to be shared and the interfaces used by viewing the source code; Refer to the shared H5 page to enter a page on the front end, and enter the element information to be displayed in the entered page; The element information includes attribute name, attribute type, associated ID, default value, prompt information, attribute length, validation rule, selector, sorting, whether required, whether read-only, whether crawling, whether enabled, whether passing data, whether obtaining data and remarks; When entering the element information to be displayed in the entered page, it further includes: (1) If the value of a page element is a fixed value, fill it in the default field and the backend will return the default value as the value; (2) If the value of the element is crawled through a shared H5 page, enter the crawling expression, and the backend will crawl the corresponding content of the H5 page through the relevant methods of JSOUP and return it as the value; (3) If the value of the element is obtained through an API interface, you need to enter the basic information of the API interface first, and then enter the corresponding interface ID in the field. The backend will find the corresponding interface information through the associated ID, call the interface through the Hutool tool class, and return the return result of the interface as the value; If the resource is an API interface converted to a general API interface, the operation is as follows: The front end enters the first page as the home page of the application. According to the parameters required by the interface, the corresponding page element information is added to the entered page. The element information needs to enter whether to pass the data identifier. The third party determines whether to pass it as a parameter when calling the next page based on the field information; The front end enters the second page as the result page of the application. According to the result returned by the interface, the corresponding page element information is added to the result page entered in the previous step. The back end obtains the interface return value through the tool class of Hutool, and implements the parsing of the interface result through the configured parsing method name and the reflection mechanism of Java, and assigns the final result to the value attribute of the element. Enter the button information in the first page, and enter the page code of the second page in the button's goto field; S4. The third party displays the result page based on the page information and button information returned by the general interface.

2. The method for converting to a general API interface for interaction according to claim 1, characterized in that: In step S4, the third party parses the page information and button information returned by the general interface to its own page according to the standard, clicks the button to trigger the general interface again, parses the data to the second page according to the standard, and displays the result page.

3. A device for converting to a general API interface for interaction, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 2.

Citation Information

Patent Citations

  • Interactive selected web crawler establishment method and system based on page elements

    CN107609150A

  • Page returning method and device, equipment and storage medium

    CN113468443A