Method for converting WebAPP into API service interface

文档序号:1577644 发布日期:2020-01-31 浏览:19次 中文

阅读说明:本技术 将WebAPP转换为API服务接口的方法 (Method for converting WebAPP into API service interface ) 是由 成超 殷际峰 于 2019-09-24 设计创作,主要内容包括:本发明公开了将WebAPP转换为API服务接口的方法,涉及软件领域,其中,方法通过利用Phantomjs和Selenium模拟用户进行WebAPP的操作动作,将获取的操作动作及操作内容转换为API服务接口的输入参数,对操作动作返回的结果进行解析,将解析结果作为API服务接口的输出参数。本发明无需对在线WebApp项目代码进行修改,只需要基于在线WebApp进行封装,并将用户的操作自动转换成API服务接口的输入参数和输出参数,对原WebApp无入侵性,能快速将网页端WebApp应用转换为API服务接口,其优势在于,在无需要投入大量研发团队开发OPEN-API平台情况下,能够快速实现将WebApp转换为API服务接口,实现与与第三方平台的合作对接,降低了开发成本,增加了WebApp的应用场景。(The invention discloses a method for converting WebAPP into an API service interface, which relates to the field of software, wherein the method comprises the steps of simulating the operation action of WebAPP by a user through Phantomjs and Selenium, converting the obtained operation action and operation content into input parameters of the API service interface, analyzing the result returned by the operation action, and taking the analyzed result as the output parameters of the API service interface. The method and the device have the advantages that under the condition that a large amount of research and development teams are not required to develop an OPEN-API platform, the WebApp can be quickly converted into the API service interface, the cooperative docking with a third-party platform is realized, the development cost is reduced, and the application scene of the WebApp is increased.)

1, A method for converting WebAPP into API service interface, comprising:

obtaining input parameters of the API service interface, wherein the input parameters comprise: operation actions and operation contents;

simulating the user to execute the operation action according to the operation content by using Phantomjs and Selenium;

converting result page data returned by the operation action to obtain a response result;

analyzing the response result to obtain an analysis result as an output parameter of the API service interface;

the response result includes one or more of a Json format object, an Xml format object, an Html format object, a Byte stream data object, and a picture object.

2. The method of for converting WebAPP into an API as recited in claim 1, wherein Phantomjs obtains user identity information in real-time, stores and maintains the user identity information, and the user identity information includes Cookie and Token.

3. The method of transforming WebAPP into an API service interface as claimed in any one of claims 1 or 2 to , wherein the parsing of the Json format object is specifically to transform the Json format object based on a Python Json library and generate Json data in a preset output format as a parsing result.

4. The method of transforming WebAPP into the API service interface as recited in any one of claims 1 and 2 to , wherein the parsing of the Xml format object is performed based on a Beautiful Soup XML parser parsing the Xml format object and generating Json data in a preset output format as a parsing result.

5. The method of transforming WebAPP into the API service interface as recited in any one of claims 1 or 2 to , wherein the parsing of the Html format object is specifically based on a Beautiful Soup Html engine parsing page elements and generating Json data in a preset output format as a parsing result.

6. The method of of claim 1 or 2 or wherein the parsing of the Byte stream data object is converting the Byte stream data object into a string according to an encoding and then converting the string into Json data in a predetermined output format as a parsing result.

7. The method of transforming WebAPP into an API service interface as claimed in any one of claims 1 or 2 to , wherein the parsing of the picture object is specifically that the name of the picture is uploaded to a picture server to generate a url address of a corresponding picture as a parsing result, and the url address format is Json data format.

8, kind of device for converting WebAPP into API service interface, characterized by comprising:

an input parameter acquisition module: input parameters for obtaining the API service interface, the input parameters including: operation actions and operation contents;

the user operation action simulation module: the operation action is executed according to the operation content by utilizing Phantomjs and Selenium simulation users;

a response result obtaining module: the data processing device is used for converting the result page data returned by the operation action to obtain a response result;

and the result analysis output module is used for analyzing the response result to obtain an analysis result as an output parameter of the API service interface, and the response result comprises types or more of Json format objects, Xml format objects, Html format objects, Byte stream data objects and picture objects.

An apparatus for converting WebAPP into an API service interface of , comprising:

at least processors, and a memory communicatively coupled to the at least processors;

wherein the processor is operable to perform the method of any of claims 1 to 7 to by invoking a computer program stored in the memory.

10, computer-readable storage media storing computer-executable instructions for causing a computer to perform the method of any of claims 1-7 through .

Technical Field

The invention relates to the field of software, in particular to methods for converting WebAPP into an API service interface.

Background

At present, the WebAPP is an App realized by using a webpage technology, from simple webpages for helping consumers calculate automobile rental fees to large and complex Web sites for providing a whole set of travel services for business personnel and vacationers, the WebApp belongs to the WebApp, and generally, the Web App runs on a network and a standard browser and develops an application with a specific function based on the webpage technology.

Disclosure of Invention

The invention aims to solve technical problems in the related art at least at the degree, and therefore the invention aims to provide method for quickly converting a webpage-side WebApp application into an API service interface.

The technical scheme adopted by the invention is as follows:

, an embodiment of the present invention provides a method for converting WebAPP into an API service interface, including:

obtaining input parameters of the API service interface, wherein the input parameters comprise: operation actions and operation contents;

simulating the user to execute the operation action according to the operation content by using Phantomjs and Selenium;

converting result page data returned by the operation action to obtain a response result;

analyzing the response result to obtain an analysis result as an output parameter of the API service interface;

the response result includes one or more of a Json format object, an Xml format object, an Html format object, a Byte stream data object, and a picture object.

, the Phantomjs acquires the user identity information in real time, stores and maintains the user identity information, and the user identity information comprises Cookie and Token.

, the analysis of the Json format object is specifically that the Json format object is converted based on a Python Json library and Json data in a preset output format is generated and used as an analysis result.

, the parsing of the Xml-format object is specifically that Json data in a preset output format, which is generated by parsing the Xml-format object based on the beautiful soup Xml parser, is used as a parsing result.

, analyzing the Html format object specifically includes analyzing page elements based on a Beautiful Soup Html engine and generating Json data in a preset output format as an analysis result.

, the parsing of the Byte stream data object is specifically that the Byte stream data object is converted into a character string according to the encoding, and then the character string is converted into Json data in a preset output format as a parsing result.

, the parsing of the picture object is specifically that the name of the picture is uploaded to a picture server to generate a url address of the corresponding picture as a parsing result, and the url address format is a Json data format.

In a second aspect, an embodiment of the present invention further provides apparatus for converting WebAPP into an API service interface, where the apparatus includes:

an input parameter acquisition module: input parameters for obtaining the API service interface, the input parameters including: operation actions and operation contents;

the user operation action simulation module: the operation action is executed by simulating the user according to the operation content by utilizing Phantomjs and Selenium;

a response result obtaining module: the data processing device is used for converting the result page data returned by the operation action to obtain a response result;

and the result analysis output module is used for analyzing the response result to obtain an analysis result as an output parameter of the API service interface, and the response result comprises or more of a Json format object, an Xml format object, an Html format object, a Byte stream data object and a picture object.

In a third aspect, an embodiment of the present invention provides kinds of kinds of devices that convert WebAPP into an API service interface, including:

at least processors, and a memory communicatively coupled to the at least processors;

wherein the processor is configured to perform the method of any of of aspect by invoking a computer program stored in the memory.

In a fourth aspect, embodiments of the invention provide computer-readable storage media storing computer-executable instructions for causing a computer to perform the method of any of aspect .

The embodiment of the invention has the beneficial effects that:

the embodiment of the invention carries out WebAPP operation actions by using Phantomjs and Selenium simulation users, obtains the operation actions and operation contents as input parameters of an API service interface, converts result page data returned by the operation actions to obtain response results, and finally analyzes the response results to obtain analysis results as output parameters of the API service interface, wherein the response results comprise: a Json format object, an Xml format object, an Html format object, a Byte stream data object, and a picture object. According to the embodiment of the invention, the online WebApp project code is not required to be modified, only the online WebApp is required to be packaged, the input parameter and the output parameter which are used as the API service interface are extracted, the source code is not invasive, the webpage end WebApp application is quickly converted into the API service interface, and the WebApp only applied by the webpage end can quickly realize the cooperative docking of the API interface service of the WebApp and a third-party platform under the condition that a large amount of research and development teams are not required to develop the OPEN-API platform, so that the development cost is reduced, and the application range of the WebApp is expanded.

is generally applicable to software domains that require converting a WebApp application into an API service interface.

Drawings

FIG. 1 is a flowchart illustrating an implementation embodiment of a method for converting WebAPP into an API service interface;

FIG. 2 is a flowchart illustrating a specific embodiment of a method for converting WebAPP into an API service interface in accordance with the present invention;

FIG. 3 is a block diagram illustrating an embodiment of converting WebAPP into an API service interface device.

Detailed Description

It should be apparent that the drawings in the following description are only examples of the invention, and other drawings and embodiments can be obtained by those skilled in the art without creative effort.

Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

The terms of the present invention are described below:

APP: the software is installed on the intelligent terminal.

Application Programming Interface (API), predefined functions, are intended to provide applications and developers the ability to access sets of routines based on certain software or hardware, without accessing source code or understanding the details of the internal workings.

WebKit is open source browser engines.

Xml, a subset of standard generalized markup language, is markup languages used to mark electronic documents to be structured.

Html applications under the standard universal Markup Language (Hyper Text Markup Language) are not programming languages but Markup languages (Markup languages).

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:用于提供文档的回顾处理的计算机实现的方法和系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!