Plug-in interface conversion method, device and equipment and storage medium
Through the service program integrating Playwright and Flask frameworks, the front-end interface is called directly in the browser, solving the problem of back-end development language conversion and realizing low-cost and high-maintainability interface conversion.
Patent Information
- Application Number
- CN202311862459.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-07-01
AI Technical Summary
When developing network interfaces in the back-end, due to the differences in front-end development languages, the existing technology needs to convert the development language or improve the JavaScript engine and service framework, resulting in high labor costs and high difficulty and poor maintenance.
By integrating the Playwright and Flask frameworks into the service program, using the HTTP interface to receive requests, determine the browser target page, and send interface call instructions, directly call the browser interface and return the results, without language conversion or engine improvements.
It saves a lot of labor costs and has good maintainability, simplifies the development process and reduces the difficulty.
Smart Images

Figure CN120234162A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer network programming, and particularly to an external plug-in interface conversion method, apparatus, device, and storage medium. Background Art
[0002] With the development of the Internet, more and more application programs are transforming from traditional desktop applications to web applications. Desktop applications generally run on local computers, while web applications generally run on the Internet through browsers. Existing web applications generally adopt a front-end and back-end separation approach for development. The back-end may be developed using one of languages such as Java, C#, Python, etc., and the front-end is generally developed using the JavaScript language. Sometimes when developing a network interface at the back-end, it is found that the front-end has already developed the same local interface or function, but due to the different development languages, the local interface or function developed by the front-end cannot be directly applied to the back-end. It is necessary to convert the development language or improve the JavaScript engine and service framework to apply the local interface or function developed by the front-end, which is difficult and costly. Summary of the Invention
[0003] This application provides an external plug-in interface conversion method, apparatus, device, and storage medium, which can save a large amount of labor costs without converting the development language or improving the JavaScript engine and service framework, and has good maintainability.
[0004] In a first aspect, this application provides an external plug-in interface conversion method, including:
[0005] Integrate a first framework and a second framework into a pre-created service program, where the first framework enables the service program to have the ability to obtain page information of a browser and call a first interface, and the second framework enables the service program to have the ability to provide a Hypertext Transfer Protocol (HTTP) interface, where the first interface is a JS script interface or function;
[0006] Receive a first request sent by a client according to the HTTP interface, where the first request includes an HTTP interface call name;
[0007] Determine a browser target page containing a target first interface according to the HTTP interface call name, and after connecting to the browser target page in a preset manner, send an interface call instruction to the browser through the service program;
[0008] The browser invokes the target first interface according to the interface invocation instruction, executes the corresponding action to obtain an invocation result, and sends the invocation result to the client.
[0009] In one or more possible embodiments, determining the browser target page including the target first interface according to the HTTP interface invocation name includes:
[0010] Determine a new page opening instruction and a navigation command corresponding to the HTTP interface invocation name according to the HTTP interface invocation name;
[0011] Determine the browser target page including the target first interface according to the new page opening instruction and the navigation command.
[0012] In one or more possible embodiments, determining the browser target page including the target first interface according to the new page opening instruction and the navigation command includes:
[0013] Determine the new page information of the browser according to the new page opening instruction, so that the browser opens a new page according to the new page opening instruction and returns a confirmation message for opening the new page;
[0014] Determine the browser target page including the target first interface according to the confirmation message for opening the new page and the navigation command, so that the browser opens the browser target page including the target first interface according to the navigation command.
[0015] In one or more possible embodiments, connecting to the browser target page in a preset manner includes:
[0016] Determine a connection establishment instruction according to the confirmation message of the browser target page, where the confirmation message of the browser target page is returned after the browser opens the browser target page including the target first interface according to the navigation command;
[0017] Determine to connect the first frame to the browser target page in a preset connection manner according to the connection establishment instruction.
[0018] In one or more possible embodiments, sending the invocation result to the client includes:
[0019] Encapsulate the invocation result to obtain a first encapsulated message, and send the first encapsulated message to the client;
[0020] Alternatively, extract fields from the invocation result, encapsulate the extracted fields to obtain a second encapsulated message, and send the second encapsulated message to the client.
[0021] In a second aspect, the present application further provides an external interface conversion device, including:
[0022] A service program determination module, configured to integrate a first framework and a second framework into a pre-created service program, where the first framework enables the service program to have the ability to obtain page information of a browser and call a first interface, and the second framework enables the service program to have the ability to provide a Hypertext Transfer Protocol (HTTP) interface, where the first interface is a JS script interface or function;
[0023] A request receiving module, configured to receive a first request sent by a client according to the HTTP interface, where the first request includes an HTTP interface call name;
[0024] A target page determination module, configured to determine a browser target page including a target first interface according to the HTTP interface call name, and after connecting to the browser target page in a preset manner, send an interface call instruction to the browser through the service program;
[0025] A call result sending module, through which the browser calls the target first interface according to the interface call instruction, executes corresponding actions, obtains a call result, and sends the call result to the client.
[0026] In one or more possible embodiments, the target page determination module is specifically configured to:
[0027] Determine a new page opening instruction and a navigation command corresponding to the HTTP interface call name according to the HTTP interface call name;
[0028] Determine a browser target page including a target first interface according to the new page opening instruction and the navigation command.
[0029] In one or more possible embodiments, the target page determination module is specifically configured to:
[0030] Determine new page information of the browser according to the new page opening instruction, so that the browser opens a new page according to the new page opening instruction and returns a confirmation message for opening the new page;
[0031] Determine a browser target page including a target first interface according to the confirmation message for opening the new page and the navigation command, so that the browser opens the browser target page including the target first interface according to the navigation command.
[0032] In one or more possible embodiments, the target page determination module is specifically configured to:
[0033] Determine a connection establishment instruction according to the confirmation information of the browser target page, where the confirmation information of the browser target page is returned by the browser after opening the browser target page including the target first interface according to the navigation command;
[0034] Determine to connect the first framework to the browser target page in a preset connection manner according to the connection establishment instruction.
[0035] In one or more possible embodiments, the call result sending module is specifically configured to:
[0036] Encapsulate the call result to obtain a first encapsulated message, and send the first encapsulated message to the client;
[0037] Alternatively, extract fields from the call result, encapsulate the extracted fields to obtain a second encapsulated message, and send the second encapsulated message to the client.
[0038] In a third aspect, the present application further provides an external interface conversion device, where the device includes:
[0039] At least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of the first aspects.
[0040] In a fourth aspect, the present application further provides a storage medium, where the storage medium stores a computer program, and the computer program is used to cause a computer to execute the method according to any one of the first aspects.
[0041] According to an external interface conversion method, device, device and storage medium provided by the present application, there is no need to convert the development language or improve the JavaScript engine and service framework, which can save a large amount of labor costs and has good maintainability. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application, and do not constitute an improper limitation of the present application.
[0043] Figure 1 Is a flowchart of an external interface conversion method provided according to an embodiment;
[0044] Figure 2 Is a structural block diagram of an external interface conversion method provided according to an embodiment;
[0045] Figure 3 It is an interaction flowchart of an external interface conversion method provided according to an embodiment;
[0046] Figure 4 It is a module diagram of an external interface conversion device provided according to an embodiment;
[0047] Figure 5 It is a module diagram of an external interface conversion device provided according to an embodiment;
[0048] Figure 6 It is a schematic diagram of a storage medium provided according to an embodiment. Detailed implementation manners
[0049] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a 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 those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present invention.
[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0051] In the existing related technologies, with the development of the Internet, more and more application programs are being transformed from traditional desktop application programs into web application programs. Desktop application programs generally run on local computers, while web application programs generally run on the Internet through browsers; existing web applications generally adopt a front-end and back-end separation method for development. The back-end may be developed using one of languages such as Java, C#, Python, etc., and the front-end is generally developed using the JavaScript language. Sometimes when developing a web interface at the back-end, it is found that the front-end has already developed the same local interface or function, but due to the different development languages, the local interface or function developed by the front-end cannot be directly applied to the back-end. It is necessary to convert the development language or improve the JavaScript engine and service framework in order to apply the local interface or function developed by the front-end, which increases a lot of unnecessary human resource consumption, and is also difficult and costly.
[0052] Generally speaking, there are three ways to convert local interfaces or functions written in the front-end JavaScript language into other network interfaces for other programs to call. The first way is for programmers to read the source code and rewrite the source code in other languages. The second way is to use a language automatic conversion program to convert JavaScript into other languages. The third way is to capture the URL (Uniform Resource Locator) accessed by the client. After the server-side parses and executes the JavaScript page, necessary nodes are added to the result and then returned to the front-end.
[0053] The advantages and disadvantages of the above three ways are described below:
[0054] First, for the first way of manually converting JavaScript code into other back-end languages by programmers reading the code, programmers need to master both JavaScript and other back-end languages, such as Java, C#, or Python. Secondly, if the front-end JavaScript code uses certain libraries and there are no versions of these libraries in other languages, then programmers also need to translate the libraries into the corresponding languages. Finally, after all the JavaScript local interfaces are translated into back-end languages, testers are required to conduct unit tests and integration tests. This method consumes a large amount of human resources and time. The first method of manually converting JavaScript into other back-end languages requires the highest labor cost among these three methods. Developers need to first figure out the process of the original code and convert it into the target back-end language. Moreover, some problems depending on language features may be encountered during the development process, which will further increase the development difficulty. After development, unit tests and integration tests are also required to verify that they are consistent with the original code logic and process. The effect of this method is the best and the running efficiency is the highest.
[0055] The second method is to convert JavaScript code into code of other back-end languages through an automated conversion program. First, an automatic conversion device is used. The local interface written in JavaScript is used as the source language, and the language to be converted, such as Java, C#, or Python, is used as the target language. The automatic conversion program converts the local interface written in JavaScript into functions of the target language. The above-mentioned automated code conversion system analyzes the source language code after decomposing it into an abstract syntax tree or module, and then converts the abstract syntax tree or module into the target language code, thus completing the code conversion. Compared with the first method mentioned above, it saves a certain amount of manpower, but there are still many problems, such as converting the source language code After conversion to target code, the running path and output of the code remain consistent with the source language, but the readability of the converted target code will be reduced. Although the computer runs this code without any problems, it is difficult for programmers to understand it, which invisibly increases the subsequent maintenance cost; the second method is equivalent to an advanced version of manual code conversion, which is converted by an automatic conversion program. In the absence of special circumstances, this method can save a lot of development costs. However, the core problem of this method is that although the converted program is consistent with the original program in logic and process, the readability of the converted code is very low and may not be maintained later. Manual code conversion may be required. This method is only suitable for use when the amount of program code is not large.
[0056] The third method is that the server parses the JavaScript page and adds nodes before returning it to the front end. The corresponding JavaScript page is parsed on the server side, and the parsing engine directly parses and executes the JavaScript page. The event-triggered nodes or attributes are added to the JavaScript page and then returned to the front end. This is essentially the same as the front end parsing through the browser's JavaScript engine. The original JavaScript source code does not need to be modified, but the JavaScript engine and back-end service framework need to be modified, developed, and tested accordingly. The development difficulty is relatively high and the development cost is at a medium level.
[0057] Therefore, the present application provides a plug-in interface conversion method, which can convert a JavaScript local interface or function into a network interface without modifying the original JavaScript code. There is no need to manually or automatically convert the original JavaScript code, and there is no need to modify the JavaScript engine. It can save a lot of manpower costs and has good maintainability, simple development, and easy testing.
[0058] The following introduces the professional terms involved in this application:
[0059] JavaScript: Abbreviated as "JS", it is a programming language widely used in web development. It is an interpreted language that does not require converting code into machine language during compilation but interprets the code during runtime. JavaScript was initially designed to add interactivity to web pages, but with the emergence of frameworks such as Node.js, it can also be used for server-side development.
[0060] A server program is a program that provides services to clients or browsers. Generally, a server program exposes a set of interfaces to provide services such as login, calculation, and storage to clients or browsers.
[0061] Playwright is a framework for web testing and automation that can be used with browsers such as Chrome, Edge, and Firefox. With Playwright, it is convenient to obtain relevant information about browser pages and control browsers to perform operations.
[0062] Flask and Django are web application frameworks written in the Python language and are relatively popular Python server-side frameworks. They can enable Python applications to have the ability to display web pages and provide HTTP interfaces.
[0063] This application provides an external plug-in interface conversion method. The service program receives and parses requests sent by the client through the HTTP interface, determines the target browser page corresponding to the above request and the target JavaScript interface or function included in the above browser target page. The service program determines to call the target JavaScript interface or function through Playwright. The browser performs corresponding actions according to the above target JavaScript interface or function to obtain an interface call result. The browser then returns the above interface call result to the service program, and then the service program sends the above interface call result to the above client through the above HTTP interface.
[0064] As Figure 1 shown, it is a flowchart of an external plug-in interface conversion method provided by this application, including:
[0065] Step 101: Integrate the first framework and the second framework into a pre-created service program. Among them, the above first framework enables the above service program to have the ability to obtain page information of the browser and call the first interface, and the above second framework enables the above service program to have the ability to provide a Hypertext Transfer Protocol (HTTP) interface. Among them, the above first interface is a JS script interface or function;
[0066] In one or more possible embodiments, in this application, Python language is used as an example for illustration. The above-mentioned first framework is the Playwright framework, the above-mentioned second framework is the Flask framework, and the above-mentioned browser is any one of browsers such as Chrome, Edge, Firefox, etc.; the above-mentioned first interface is a JS script interface or function, and the above-mentioned JS script interface or function is a JavaScript interface or function, that is to say, the above-mentioned first interface is a JavaScript interface or function; after creating a Python service program, integrate the above-mentioned Playwright framework and Flask framework into the above-mentioned Python service program. Adding the Playwright framework is to enable the service program to have the ability to control the browser and read the page content, elements in the browser, and call JavaScript interfaces or functions; adding the Flask framework is to enable the program to have the ability to provide HTTP interfaces externally, and use Flask to add one or a group of HTTP interfaces to provide services externally.
[0067] Step 102, receive a first request sent by the client according to the above-mentioned HTTP interface, and the above-mentioned first request includes an HTTP interface call name;
[0068] In one or more possible embodiments, after integrating the above-mentioned Playwright framework and Flask framework into the above-mentioned Python service program, start the above-mentioned service program and wait for the first request sent by the client. The above-mentioned first request is an HTTP request, and the above-mentioned HTTP request includes the name Py_HTTP_InterfaceA of the HTTP interface.
[0069] Step 103, determine a browser target page containing the target first interface according to the above-mentioned HTTP interface call name, and after connecting to the above-mentioned browser target page in a preset manner, send an interface call instruction to the above-mentioned browser through the above-mentioned service program;
[0070] In one or more possible embodiments, after receiving a request from Py_HTTP_InterfaceA, the above Python program can determine the browser target page containing the target first interface. After connecting to the above browser target page in a preset manner, it sends an interface call instruction to the above browser through the above service program. Specifically, when the above Python program receives a request from Py_HTTP_InterfaceA, it can determine the new page opening instruction new_page() and the navigation command goto() corresponding to the above HTTP interface call name, and determine the browser target page containing the target first interface based on the above new page opening instruction new_page() and navigation command goto(). After determining the browser target page containing the target first interface, the browser determines the connection establishment instruction chromium.connect_over_cdp() based on the confirmation information of the browser target page returned after opening the browser target page containing the target first interface according to the above navigation command, and connects the above Playwright framework to the above browser target page containing the target first interface in the CDP (Chrome DevTools Protocol) manner according to the chromium.connect_over_cdp() instruction, and then sends the interface call instruction evaluate of the Playwright framework to the above browser through the above service program.
[0071] Step 104, the above browser calls the above target first interface according to the above interface call instruction, executes the corresponding action, obtains the call result, and sends the above call result to the above client.
[0072] In one or more possible embodiments, for example, the name of the JavaScript interface or function to be called, that is, the target first interface, is JS_InterfaceA. The above service program sends the above interface call instruction evaluate to the above browser so that the above browser calls the JS_InterfaceA interface, executes the corresponding action, obtains the call result, and finally the service program sends the result returned by the JS_InterfaceA interface, that is, the call result, to the above client. There are two ways to send the above call result to the above client: First, encapsulate the above call result to obtain the first encapsulated message and send the above first encapsulated message to the above client; Second, extract the fields of the above call result, encapsulate the extracted fields to obtain the second encapsulated message, and send the above second encapsulated message to the above client.
[0073] In one or more possible embodiments, determining the browser target page containing the target first interface according to the above new page opening instruction and navigation command includes: determining the new page information of the browser according to the above new page opening instruction, so that the browser opens a new page according to the above new page opening instruction and returns the confirmation information of opening the new page; determining the browser target page containing the target first interface according to the confirmation information of opening the new page and the above navigation command, so that the browser opens the browser target page containing the target first interface according to the above navigation command; after receiving the request of the above Py_HTTP_InterfaceA, the browser launch instruction chromium.launch() will be called first. The browser opens according to the above browser launch instruction chromium.launch() and returns the browser opening information to the above service program. Then, the new page opening instruction new_page() of the Playwright framework is called. The browser opens the corresponding page according to the above new page opening instruction new_page() and returns the browser new page opening information to the above service program. Finally, the navigation command goto() of the Playwright framework is called. The browser opens the page containing the JavaScript interface or function to be converted according to the above navigation command goto().
[0074] In one or more possible embodiments, such as Figure 2As shown in the figure, it is a structural block diagram of an external interface conversion method provided by this application, including a client 20, a service program 21, and a browser 22; the service program 21 includes a second service package 211 and a first service package 212. The above client 20 sends a first request to the service program 21. The above second service package 211 is an HTTP service package, and the HTTP service package is a Flask or Django framework. In this application, the Flask framework is used for data transmission. The above Flask framework can enable the above service program to have the ability to provide a Hypertext Transfer Protocol (HTTP) interface, that is, it can provide an HTTP interface. The service program 21 receives the first request sent by the above client 20 through the above HTTP interface, and obtains the browser target page and the target first interface included in the browser target page by parsing the above first request. The above target first interface refers to a target script JS interface or function. The full name of the above JS interface or function is a JavaScript interface or function. Therefore, the above target first interface is a target JavaScript interface or function; the above service program 21 sends an interface call instruction, that is, the first service package 212 sends an interface call instruction to the browser target page of the above browser 22 that includes the target first interface; the browser target page executes corresponding actions according to the above interface call instruction to obtain a call result, and sends the above call result to the above service program 21. Finally, the service program 21 sends the above call result to the above client 20 through the above HTTP interface.
[0075] In one or more possible embodiments, as Figure 3 shown, it is an interaction flowchart of the client, the service program, and the browser, including:
[0076] Step 301, the client sends an HTTP request to the service program;
[0077] Step 302, the service program receives the above HTTP request and calls the browser startup instruction chromium.launch() to send to the browser;
[0078] Step 303, the browser starts according to the above browser startup instruction chromium.launch() and returns the information of the opened browser to the service program;
[0079] Step 304, the service program calls the new page opening instruction new_page() to send to the browser according to the information of the opened browser;
[0080] Step 305, the browser opens the corresponding page according to the above new page opening instruction new_page() and returns the information of the newly opened browser page to the above service program;
[0081] Step 306: The service program calls the navigation command goto() according to the information of the browser opening a new page and sends it to the browser;
[0082] Step 307: The browser opens a page containing the JavaScript interface or function to be converted according to the navigation command goto() and returns the confirmation information of the browser target page to the above service program;
[0083] Step 308: The service program determines the connection establishment instruction chromium.connect_over_cdp() according to the confirmation information of the browser target page, connects to the browser in the CDP manner, and then sends the interface call instruction evaluate to the browser;
[0084] Step 309: The browser calls the JS_InterfaceA interface according to the interface call instruction evaluate and obtains the call result;
[0085] Step 3010: The browser sends the call result to the above service program;
[0086] Step 3011: The service program sends the call result to the client;
[0087] Step 3012: The client receives the call result.
[0088] Based on the same inventive concept, the present application also provides an external interface conversion device, as Figure 4 shown, including:
[0089] A service program determination module 401, configured to integrate a first framework and a second framework into a pre-created service program, wherein the first framework enables the service program to have the ability to obtain the page information of the browser and call a first interface, and the second framework enables the service program to have the ability to provide a Hypertext Transfer Protocol (HTTP) interface, wherein the first interface is a JS script interface or function;
[0090] A request receiving module 402, configured to receive a first request sent by a client according to the above HTTP interface, where the first request includes an HTTP interface call name;
[0091] A target page determination module 403, configured to determine a browser target page containing a target first interface according to the above HTTP interface call name, connect to the browser target page in a preset manner, and then send an interface call instruction to the browser through the above service program;
[0092] The call result sending module 404 uses the above browser to call the above target first interface according to the above interface call instruction, performs the corresponding actions, obtains the call result, and sends the above call result to the above client.
[0093] In one or more possible embodiments, the above target page determination module 403 is specifically configured to:
[0094] Determine a new page opening instruction and a navigation command corresponding to the above HTTP interface call name according to the above HTTP interface call name;
[0095] Determine a browser target page including the target first interface according to the above new page opening instruction and navigation command.
[0096] In one or more possible embodiments, the above target page determination module 403 is specifically configured to:
[0097] Determine the new page information of the browser according to the above new page opening instruction, so that the above browser opens a new page according to the above new page opening instruction and returns the confirmation information for opening the new page;
[0098] Determine a browser target page including the target first interface according to the above confirmation information for opening the new page and the above navigation command, so that the above browser opens the browser target page including the target first interface according to the above navigation command.
[0099] In one or more possible embodiments, the above target page determination module 403 is specifically configured to:
[0100] Determine a connection establishment instruction according to the confirmation information of the browser target page, where the confirmation information of the browser target page is returned after the above browser opens the browser target page including the target first interface according to the above navigation command;
[0101] Determine to connect the above first frame to the above browser target page in a preset connection manner according to the above connection establishment instruction.
[0102] In one or more possible embodiments, the above call result sending module 404 is specifically configured to:
[0103] Encapsulate the above call result to obtain a first encapsulated message, and send the above first encapsulated message to the above client;
[0104] Alternatively, extract the fields of the above call result, encapsulate the extracted fields to obtain a second encapsulated message, and send the above second encapsulated message to the above client.
[0105] Based on the same inventive concept, the present application further provides an external interface conversion device, including at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned external interface conversion method.
[0106] As Figure 5 shown, the device includes a processor 501, a memory 502, a communication interface 503, and a bus 504. Among them, the processor 501, the memory 502, and the communication interface 503 are interconnected through the bus 504.
[0107] The processor 501 is configured to read and execute the instructions in the memory 502 to enable the at least one processor to execute the external interface conversion method provided in the above embodiment.
[0108] The memory 502 is used to store various instructions and programs of the external interface conversion method provided in the above embodiment.
[0109] The bus 504 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, Figure 5 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.
[0110] The processor 501 can be a central processing unit (CPU), a network processor (NP), a graphic processing unit (GPU), or any combination of CPU, NP, and GPU. It can also be a hardware chip. The above-mentioned hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above-mentioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0111] In addition, the present application also provides a computer-readable storage medium. As Figure 6 shown, the computer storage medium stores a computer program, and the computer program is used to make a computer execute any one of the methods in the above embodiments.
[0112] The memory may include a readable medium in the form of volatile memory, such as a random access memory (RAM) 601 and / or a cache memory 602, and may further include a read-only memory (ROM) 603.
[0113] The memory may also include a program / utilities 605 having a set (at least one) of program modules 604. Such program modules 604 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment.
[0114] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0115] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices produce means for implementing the functions specified in the Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0116] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in the Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0117] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in the Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0118] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these modifications and variations.
Claims
1. An external interface conversion method, characterized in that, Including: Integrate the first framework and the second framework into a pre-created service program, where the first framework enables the service program to have the ability to obtain page information of a browser and call a first interface, and the second framework enables the service program to have the ability to provide a HyperText Transfer Protocol (HTTP) interface, where the first interface is a JS script interface or function; Receive a first request sent by a client according to the HTTP interface, where the first request includes an HTTP interface call name; According to the HTTP interface call name, determine a browser target page containing a target first interface, and after connecting to the browser target page in a preset manner, send an interface call instruction to the browser through the service program; The browser calls the target first interface according to the interface call instruction and executes a corresponding action to obtain a call result, and sends the call result to the client.
2. The method according to claim 1, wherein The determining the browser target page containing the target first interface according to the HTTP interface call name includes: According to the HTTP interface call name, determine a new page opening instruction and a navigation command corresponding to the HTTP interface call name; According to the new page opening instruction and the navigation command, determine a browser target page containing the target first interface.
3. The method according to claim 2, wherein The determining the browser target page containing the target first interface according to the new page opening instruction and the navigation command includes: According to the new page opening instruction, determine new page information of the browser, so that the browser opens a new page according to the new page opening instruction and returns a confirmation message for opening the new page; According to the confirmation message for opening the new page and the navigation command, determine a browser target page containing the target first interface, so that the browser opens the browser target page containing the target first interface according to the navigation command.
4. The method according to claim 3, wherein The connecting to the browser target page in a preset manner includes: According to the confirmation message of the browser target page, determine a connection establishment instruction, where the confirmation message of the browser target page is returned after the browser opens the browser target page containing the target first interface according to the navigation command; According to the connection establishment instruction, determine to connect the first framework to the browser target page in a preset connection manner.
5. The method according to claim 1, characterized in that, The sending the call result to the client includes: Encapsulate the call result to obtain a first encapsulated message, and send the first encapsulated message to the client; Or, extract fields from the call result, encapsulate the extracted fields to obtain a second encapsulated message, and send the second encapsulated message to the client.
6. An external interface conversion device, characterized in that, Including: A service program determination module, configured to integrate the first framework and the second framework into a pre-created service program, where the first framework enables the service program to have the ability to obtain page information of a browser and call a first interface, and the second framework enables the service program to have the ability to provide a HyperText Transfer Protocol (HTTP) interface, where the first interface is a JS script interface or function; A request receiving module, configured to receive a first request sent by a client according to the HTTP interface, where the first request includes an HTTP interface call name; A target page determining module, configured to determine a browser target page including a target first interface according to the HTTP interface call name, and after connecting to the browser target page in a preset manner, send an interface call instruction to the browser through the service program; A call result sending module, configured to call the target first interface according to the interface call instruction through the browser, execute corresponding actions, obtain a call result, and send the call result to the client.
7. The device according to claim 6, characterized in that, The target page determining module is specifically configured to: Determine a new page opening instruction and a navigation command corresponding to the HTTP interface call name according to the HTTP interface call name; Determine a browser target page including a target first interface according to the new page opening instruction and the navigation command.
8. The device according to claim 7, characterized in that, The target page determining module is specifically configured to: Determine new page information of the browser according to the new page opening instruction, so that the browser opens a new page according to the new page opening instruction and returns a confirmation message for opening the new page; Determine a browser target page including a target first interface according to the confirmation message for opening the new page and the navigation command, so that the browser opens the browser target page including the target first interface according to the navigation command.
9. The device according to claim 8, characterized in that, The target page determining module is specifically configured to: Determine a connection establishment instruction according to the confirmation message of the browser target page, where the confirmation message of the browser target page is returned after the browser opens the browser target page including the target first interface according to the navigation command; Determine to connect the first framework to the browser target page in a preset connection manner according to the connection establishment instruction.
10. The device according to claim 6, characterized in that, The call result sending module is specifically configured to: Encapsulate the call result to obtain a first encapsulated message, and send the first encapsulated message to the client; Alternatively, extract fields from the call result, encapsulate the extracted fields to obtain a second encapsulated message, and send the second encapsulated message to the client.
11. An external interface conversion device, characterized in that, The device includes: At least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1-5.
12. A storage medium, characterized in that, The storage medium stores a computer program, and the computer program is used to cause a computer to execute the method according to any one of claims 1-5.