CN112948727A - WebView-based data injection method, device, equipment and storage medium - Google Patents
WebView-based data injection method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN112948727A CN112948727A CN202110340209.2A CN202110340209A CN112948727A CN 112948727 A CN112948727 A CN 112948727A CN 202110340209 A CN202110340209 A CN 202110340209A CN 112948727 A CN112948727 A CN 112948727A
- Authority
- CN
- China
- Prior art keywords
- webview
- data
- uniform resource
- resource locator
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000002347 injection Methods 0.000 title claims abstract description 90
- 239000007924 injection Substances 0.000 title claims abstract description 90
- 238000000034 method Methods 0.000 title claims abstract description 59
- 238000006243 chemical reaction Methods 0.000 claims abstract description 21
- 238000004590 computer program Methods 0.000 claims description 6
- 238000012544 monitoring process Methods 0.000 claims description 4
- 230000000977 initiatory effect Effects 0.000 claims 1
- 230000004044 response Effects 0.000 description 9
- 238000004891 communication Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 239000000243 solution Substances 0.000 description 4
- 230000005540 biological transmission Effects 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 229940004975 interceptor Drugs 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
- G06F16/9566—URL specific, e.g. using aliases, detecting broken or misspelled links
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/258—Data format conversion from or to a database
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The application relates to the technical field of data acquisition, and discloses a data injection method, a device, equipment and a storage medium based on WebView, wherein the method comprises the steps of acquiring a data injection request generated by a WebView terminal and acquiring binary data; when the WebView end receives the uniform resource locator, a GET request is initiated; intercepting the GET request by an interceptor preset by a Native terminal, judging whether the uniform resource locator meets a preset condition, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into a Web object; and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject binary data into the WebView end. The application also relates to a blockchain technique, where binary data is stored in the blockchain. According to the method and the device, the interceptor intercepts the GET request, and the binary data are converted into the Web object, so that the efficiency of injecting the binary data into the WebView end is improved.
Description
Technical Field
The application relates to the technical field of data acquisition, in particular to a WebView-based data injection method, device, equipment and storage medium.
Background
WebView is a very important component for App content presentation, and Native is essential for communicating with WebView. Most of the time, the data size of Native and WebView communication interaction is not large, and the Native and WebView communication interaction is mainly based on character strings. At present, the data injection mode of the Android WebView standard is JavaScript code injection, namely, a corresponding interface is called to execute js codes, and Native data is injected. In some scenes, Native is required to inject larger binary data, such as media data like images, audio, etc.
The method comprises the steps of injecting binary data into a WebView terminal, converting first binary data into a string, namely converting the string into a hex or base64 format, then injecting the binary data string into a JavaScript terminal through an interface, and decoding the binary data string through the JavaScript terminal to obtain the binary data. In the binary data injection mode, for a large data volume, the data needs to be subjected to character serialization and decoding through a JavaScript end, and the process needs a long time, so that the efficiency of injecting the binary data into the WebView end is low. There is a need for a method capable of improving binary data injection into WebView side.
Disclosure of Invention
The embodiment of the application aims to provide a WebView-based data injection method, device, equipment and storage medium so as to improve the efficiency of binary data injection into a WebView end.
In order to solve the above technical problem, an embodiment of the present application provides a WebView-based data injection method, including:
acquiring a data injection request generated by a WebView terminal, and acquiring binary data corresponding to the data injection request through a Native terminal;
when the WebView end receives a uniform resource locator corresponding to the binary data, a GET request is initiated to the uniform resource locator through a browser object;
intercepting the GET request through an interceptor preset by the Native terminal, and judging whether the uniform resource locator meets a preset condition to obtain a judgment result;
if the judgment result is that the uniform resource locator meets the preset condition, the binary data is obtained by analyzing the uniform resource locator;
converting the binary data into a Web object, and returning the Web object to the WebView terminal;
and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject the binary data into the WebView end.
In order to solve the above technical problem, an embodiment of the present application provides a WebView-based data injection apparatus, including:
the binary data acquisition module is used for acquiring a data injection request generated by the WebView terminal and acquiring binary data corresponding to the data injection request through the Native terminal;
a uniform resource locator receiving module, configured to initiate a GET request to a uniform resource locator through a browser object when the WebView end receives the uniform resource locator corresponding to the binary data;
a judgment result obtaining module, configured to intercept the GET request through an interceptor preset at the Native end, and judge whether the uniform resource locator meets a preset condition, so as to obtain a judgment result;
a uniform resource locator analyzing module, configured to analyze the uniform resource locator to obtain the binary data if the determination result indicates that the uniform resource locator meets the preset condition;
the binary data conversion module is used for converting the binary data into a Web object and returning the Web object to the WebView terminal;
and the binary data injection module is used for performing data type conversion on the Web object according to a preset data type when the condition that the Web object returns to the WebView end is monitored, so that the binary data is injected into the WebView end.
In order to solve the technical problems, the invention adopts a technical scheme that: a computer device is provided that includes, one or more processors; a memory to store one or more programs to cause the one or more processors to implement the WebView-based data injection method of any of the above.
In order to solve the technical problems, the invention adopts a technical scheme that: a computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements the WebView-based data injection method of any of the above.
The embodiment of the invention provides a data injection method, a device, equipment and a storage medium based on WebView. The method comprises the following steps: acquiring a data injection request generated by a WebView terminal and acquiring binary data; when the WebView end receives the uniform resource locator, a GET request is initiated; intercepting the GET request by an interceptor preset by a Native terminal, judging whether the uniform resource locator meets a preset condition, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into a Web object; and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject binary data into the WebView end. According to the embodiment of the invention, the interceptor intercepts the GET request, the binary data is converted into the Web object, and finally the data type conversion is carried out on the Web object, so that the binary data is injected into the WebView terminal without transcoding in a JavaScript environment, and the efficiency of injecting the binary data into the WebView terminal is improved.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is a schematic diagram of an application environment of a WebView-based data injection method provided by an embodiment of the present application;
FIG. 2 is a flowchart of an implementation of a WebView-based data injection method provided in an embodiment of the present application;
FIG. 3 is a flowchart of an implementation of a sub-process in a WebView-based data injection method according to an embodiment of the present application;
FIG. 4 is a flowchart of another implementation of a sub-process in a WebView-based data injection method provided in an embodiment of the present application;
FIG. 5 is a flowchart of another implementation of a sub-process in a WebView-based data injection method provided in an embodiment of the present application;
FIG. 6 is a flowchart of another implementation of a sub-process in a WebView-based data injection method provided in an embodiment of the present application;
FIG. 7 is a flowchart of another implementation of a sub-process in a WebView-based data injection method according to an embodiment of the present application;
FIG. 8 is a schematic diagram of a WebView-based data injection apparatus provided by an embodiment of the present application;
fig. 9 is a schematic diagram of a computer device provided in an embodiment of the present application.
Detailed Description
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 application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
The present invention will be described in detail below with reference to the accompanying drawings and embodiments.
Referring to fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as a web browser application, a search-type application, an instant messaging tool, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the WebView-based data injection method provided in the embodiment of the present application is generally executed by a server, and accordingly, the WebView-based data injection device is generally configured in the server.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring to FIG. 2, FIG. 2 illustrates an embodiment of a WebView-based data injection method.
It should be noted that, if the result is substantially the same, the method of the present invention is not limited to the flow sequence shown in fig. 2, and the method includes the following steps:
s1: and acquiring a data injection request generated by the WebView terminal, and acquiring binary data corresponding to the data injection request through the Native terminal.
Specifically, when data needs to be injected into the WebView end, the WebView end generates a data injection request, and after the server obtains the data injection request, the Native end obtains corresponding binary data. For example, when camera real-time frame data needs to be injected to a WebView end, a camera needs to be turned on and the real-time frame data needs to be acquired, the real-time frame data is sent to a Native end first, and the real-time frame data exists in a form of binary data, that is, a form of byte array.
The Webview end is an engine based on webkit, can analyze DOM elements and display a control of an html page, has the same principle as a browser for displaying the page, and can be regarded as a browser. The Native terminal refers to an Android Native terminal and is a client based on an Android system. The android end corresponds to a Native layer, the Native layer is developed by C + + generally relative to the bottom layer of a Java layer, and the Native layer is deployed with common local services, link libraries and the like. In the embodiment, the binary data is intercepted and converted through the communication between the Native terminal and the Webview terminal, so that the binary data is injected into the Webview terminal.
Referring to fig. 3, fig. 3 shows an embodiment of step S1, which includes:
s11: and acquiring a data injection request generated by the WebView terminal.
S12: and acquiring a search path corresponding to the data injection request by analyzing the data injection request.
S13: and acquiring binary data corresponding to the search path through a Native terminal.
Specifically, because the data injection request generated by the WebView end has different data sources and different stored paths corresponding to the data injection request, the data injection request needs to be analyzed, and different types of data requests are distinguished through a Path function, that is, a search Path corresponding to the data injection request is obtained. And then corresponding binary data is obtained according to the search path.
The Path function is a DOS (disk operating system) Path setting command, the function is a search Path of an executable file of the equipment, when the executable file is operated, the DOS searches the file in a current directory firstly, and if the executable file is found, the DOS is operated; if the file cannot be found, the file is searched in the directory one by one according to the Path set by the Path function. The search path refers to a path in which the data injection request corresponds to storage or queryable of data. For example, if the data corresponding to the data injection request is the data of the requested camera real-time frame, the generated uniform resource locator is "http:// pa. If the real-time recording data is requested, the uniform resource locator is set to be http:// pamina.
In the implementation, the corresponding search path is obtained by analyzing the data injection request, and the binary data is obtained according to the search path, so that different data injection requests are distinguished, the corresponding binary data is quickly obtained, and the efficiency of binary injection into the WebView end is improved.
S2: and when the WebView end receives the uniform resource locator corresponding to the binary data, a GET request is initiated to the uniform resource locator through the browser object.
Specifically, the binary data is acquired at the Native end, but the binary data cannot reach the WebView end. Therefore, a uniform resource locator corresponding to the binary data needs to be generated at the Native terminal, the uniform resource locator is sent to the WebView terminal, and the WebView terminal is informed of new generation of the binary data, so that when the WebView terminal receives the uniform resource locator corresponding to the binary data, a GET request is initiated to the uniform resource locator through the browser object.
The browser object is XMLHttpRequest, and the XMLHttpRequest (XHR) is an Application Program Interface (API) object, wherein the method can be used for transmitting data at the browser and server sides. This object is provided by the JavaScript environment of the browser. The purpose of obtaining data from XMLHttpRequest is to continuously modify a loaded page, which is the underlying concept of the Ajax design. The protocol used by XMLHttpRequest is different from HTTP, and not only data in XML format but also JSON, HTML, or plain text can be supported. In the embodiment of the application, the GET request is initiated to the uniform resource locator by calling the method in the browser object.
The GET request is a request for requesting data from a server. In the embodiment of the application, a GET request is initiated to the uniform resource locator through the browser object, so that a WebView terminal initiates a request for acquiring binary data.
Referring to fig. 4, fig. 4 shows an embodiment of step S2, which includes:
s21: and acquiring the uniform resource locator corresponding to the binary data.
S22: and sending the uniform resource locator to the WebView terminal in a mode of calling JavaScript codes.
Specifically, binary data is acquired at a Native terminal, and a uniform resource locator corresponding to the binary data is generated. In order to reduce the data volume and improve the transmission efficiency, a uniform resource locator is sent to the WebView end by calling a JavaScript code, so that the WebView end can be informed of new binary data generation at the Native end.
The mode of calling the JavaScript code means that the JavaScript code is injected into the JavaScript by evaluateJavaScript, and the uniform resource locator is sent to the WebView end.
S23: and when the WebView end receives the uniform resource locator, calling the browser object to initiate a GET request to the uniform resource locator.
Specifically, the uniform resource locator is received at the WebView end by calling a JavaScript code form. And calling a browser object, namely calling a method in the XMLHttpRequest, at the WebView end to initiate a GET request to the uniform resource locator.
In the implementation, the JavaScript code is called to send the uniform resource locator to the WebView end, and the GET request is initiated at the WebView end, so that the binary data acquisition request is initiated at the WebView end, the binary data can be conveniently injected into the WebView end subsequently, and the efficiency of injecting the binary data into the WebView end can be improved.
Referring to fig. 5, fig. 5 shows a specific implementation manner after step S23, which includes:
s231: and responding to the corresponding type of the browser object to acquire a preset data type.
S232: and converting the data type of the binary data into a preset data type by adopting a traversal mode, wherein the preset data type comprises an arraybuffer type and a blob type.
Specifically, in this embodiment of the present application, the type corresponding to the response browser object refers to a response xmlhttprequest. It allows us to manually set the type of data returned. If it is set to an empty string, it will use the default "text" type. In the embodiment of the application, a preset data type is obtained by responding to an xmlhttprequest.
The preset data type is set according to the actual situation and comprises an arraybuffer type and a blob type. The arraybuffer type refers to typed arrays. A blob type refers to a binary large object, which is a container that can store binary files.
In the implementation, the corresponding type of the browser object is responded to obtain the preset data type, and the data type of the binary data is converted into the preset data type in a traversal mode, so that the binary data is converted into the corresponding type, and the binary data is convenient to identify subsequently.
S3: intercepting the GET request through an interceptor preset by a Native terminal, and judging whether the uniform resource locator meets a preset condition to obtain a judgment result.
Specifically, an interceptor is preset at a Native end, the GET request is intercepted after the WebView end initiates the GET request, and whether a uniform resource locator corresponding to the GET request meets a preset condition is judged, so that a judgment result is obtained.
The preset condition is a character string set according to a domain name suffix and used for distinguishing whether the domain name corresponding to the uniform resource locator meets the requirement or not. For example, the preset condition is "com", if there is a character matching "com" in the domain name in the uniform resource locator, the result is that the uniform resource locator meets the preset condition, otherwise, the uniform resource locator does not meet the preset condition.
Further, before the GET request is intercepted by an interceptor preset at the Native terminal, an interceptor is preset at the Native terminal. The method comprises the steps that a preset Interceptor is preset with a class realizing an Interceptor interface or inherits an abstract class abstract Interceptor, defined interceptors are registered in a configuration file, and the registered and defined interceptors are quoted when an interception function is needed. In this embodiment of the present application, an interceptor registered and defined in a configuration file may set an intercepted domain name, for example, pamina.
Referring to fig. 6, fig. 6 shows a specific implementation manner of step S3, which includes:
s31: and intercepting the GET request through an interceptor preset by a Native terminal.
S32: and identifying the domain name corresponding to the uniform resource locator.
S33: and matching the domain name with the character strings corresponding to the preset conditions to obtain a judgment result.
Specifically, after the interceptor preset by the Native terminal identifies that the WebView terminal initiates the GET request, the GET request is intercepted. And acquiring a uniform resource locator corresponding to the GET request, thereby identifying a domain name corresponding to the uniform resource locator, and judging whether the domain name meets preset conditions or not, thereby achieving a judgment result.
The Domain Name (Domain Name), also called network Domain, is the Name of a certain computer or computer group on the Internet, which is composed of a string of names separated by points, and is used for positioning and identifying the computer during data transmission.
Specifically, since the domain name has a domain name suffix of ". com", ". net", ". cn", ". edu", ". top", ". xyz", and the like. Therefore, the preset condition can set the corresponding character strings according to the domain name suffixes, if the suffixes in the domain name corresponding to the uniform resource locator are matched with the character strings in the preset condition, the judgment result is that the domain name meets the preset condition, otherwise, the domain name does not meet the preset condition.
In the implementation, a GET request is intercepted through an interceptor preset by a Native terminal, a domain name corresponding to a uniform resource locator is identified, the domain name is subjected to character string matching with a character string corresponding to a preset condition to obtain a judgment result, the GET request interception and the judgment result acquisition are realized, corresponding binary data can be favorably sent to a WebView terminal, and therefore the efficiency of injecting the binary data into the WebView terminal can be favorably improved.
S4: if the judgment result is that the uniform resource locator meets the preset condition, the binary data is obtained by analyzing the uniform resource locator.
Specifically, if a suffix in the domain name corresponding to the uniform resource locator matches a character string in the preset condition, the result of the determination is that the uniform resource locator meets the preset condition. And analyzing the uniform resource locator to acquire a path corresponding to the binary data, thereby acquiring the binary data.
S5: and converting the binary data into a Web object, and returning the Web object to the WebView end.
Specifically, the Web object is a WebResourceResponse object, which is response information encapsulating a Web resource, and the response information of the Web resource includes: response data stream, encoding, MIME type, response header, status code and status description, etc.
Specifically, in the embodiment of the present application, binary data is converted into a WebResourceResponse object through an eval () function of JavaScript. The eval () function uses a JavaScript compiler that can parse JSON text and then generate a WebResourceResponse object. And then returning the Web object to the WebView end.
S6: and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject binary data into the WebView end.
Specifically, when a browser object of the WebView end monitors the return of a Web object, namely the return of the Web object is monitored through XMLHttpReques, the attribute of the Web object is obtained, and the attribute of the Web object is converted into a corresponding data type according to the preset data type, so that binary data is injected into the WebView end.
In the embodiment, a data injection request generated by a WebView terminal is obtained, and binary data is obtained; when the WebView end receives the uniform resource locator, a GET request is initiated; intercepting the GET request by an interceptor preset by a Native terminal, judging whether the uniform resource locator meets a preset condition, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into a Web object; and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject binary data into the WebView end. According to the embodiment of the invention, the interceptor intercepts the GET request, the binary data is converted into the Web object, and finally the data type conversion is carried out on the Web object, so that the binary data is injected into the WebView terminal without transcoding in a JavaScript environment, and the efficiency of injecting the binary data into the WebView terminal is improved.
Referring to fig. 7, an embodiment of step S6 is illustrated, which includes:
s61: and monitoring the Web object through a browser object of the WebView end.
S62: and when the condition that the Web object returns to the WebView end is monitored, acquiring the attribute of the Web object.
S63: and performing data type conversion on the attribute of the Web object according to a preset data type by responding to the request of the browser object so as to inject binary data into the WebView terminal.
The attribute of the Web object refers to a response data stream of the WebResourceResponse object, that is, corresponding data information. The request to respond to the browser object is implemented via an XMLHttpRequest response attribute that can return the body of the response. The type of return may be one of arraybuffer, blob, Document, JavaScript Object, or DOMString. In the embodiment of the present application, the preset data types include: arraybuffer type, blob type, then data can be returned as arraybuffer type or blob type by responding to a request by a browser object.
In the implementation, the Web object is monitored through a browser object of a WebView end, the attribute of the Web object is obtained, the attribute of the Web object is subjected to data type conversion according to a preset data type by responding to a request of the browser object, so that binary data is injected into the WebView end, and finally the binary data is injected into the WebView end.
It is emphasized that, to further ensure the privacy and security of the binary data, the binary data may also be stored in a node of a block chain.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the computer program is executed. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
Referring to fig. 8, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a WebView-based data injection apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which can be applied to various electronic devices.
As shown in fig. 8, the WebView-based data injection apparatus of the present embodiment includes: an item identifier obtaining module 71, a configuration file selecting module 72, a target version branching module 73, a warehouse source code pulling module 74, a judgment result obtaining module 75, and a successfully constructed item module 76, where:
the binary data acquisition module 71 is used for acquiring a data injection request generated by the WebView terminal and acquiring binary data corresponding to the data injection request through the Native terminal;
a uniform resource locator receiving module 72, configured to initiate a GET request to a uniform resource locator through a browser object when the WebView end receives the uniform resource locator corresponding to the binary data;
a judgment result obtaining module 73, configured to intercept the GET request through an interceptor preset at the Native end, and judge whether the uniform resource locator meets a preset condition, so as to obtain a judgment result;
a uniform resource locator analyzing module 74, configured to, if the determination result is that the uniform resource locator meets the preset condition, obtain binary data by analyzing the uniform resource locator;
the binary data conversion module 75 is used for converting the binary data into a Web object and returning the Web object to the WebView terminal;
and a binary data injection module 76, configured to, when it is monitored that the Web object returns to the WebView end, perform data type conversion on the Web object according to a preset data type, so that the binary data is injected into the WebView end.
Further, the binary data acquisition module 71 includes:
the data injection request acquisition unit is used for acquiring a data injection request generated by the WebView terminal;
the search path acquisition unit is used for acquiring a search path corresponding to the data injection request by analyzing the data injection request;
and the search path execution unit is used for acquiring binary data corresponding to the search path through a Native terminal.
Further, the uniform resource locator receiving module 72 includes:
a uniform resource locator obtaining unit, configured to obtain a uniform resource locator corresponding to the binary data;
the uniform resource locator sending unit is used for sending the uniform resource locator to the WebView terminal in a mode of calling JavaScript codes;
and the browser object calling unit is used for calling the browser object when the WebView end receives the uniform resource locator so as to initiate a GET request to the uniform resource locator.
Further, after the browser object invoking unit, the WebView-based data injection apparatus further includes:
the preset data type conversion unit is used for responding to the corresponding type of the browser object to acquire a preset data type;
the binary data conversion unit is used for converting the data type of the binary data into a preset data type in a traversal mode, wherein the preset data type comprises an arraybuffer type and a blob type.
Further, the judgment result obtaining module 73 includes:
the GET request intercepting unit is used for intercepting the GET request through an interceptor preset by a Native terminal;
the domain name identification unit is used for identifying a domain name corresponding to the uniform resource locator;
and the character string matching unit is used for performing character string matching on the domain name and the character strings corresponding to the preset conditions to obtain a judgment result.
Further, the binary data injection module 76 includes:
the Web object monitoring unit is used for monitoring the Web object through a browser object of the WebView end;
the data type acquisition unit is used for acquiring the attribute of the Web object when the condition that the Web object returns to the WebView end is monitored;
and the data injection unit is used for responding to the request of the browser object and performing data type conversion on the attribute of the Web object according to a preset data type so as to inject the binary data into the WebView terminal.
It is emphasized that, to further ensure the privacy and security of the binary data, the binary data may also be stored in a node of a block chain.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 9, fig. 9 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 8 includes a memory 81, a processor 82, and a network interface 83 communicatively connected to each other via a system bus. It is noted that only a computer device 8 having three components, a memory 81, a processor 82, and a network interface 83, is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 81 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 81 may be an internal storage unit of the computer device 8, such as a hard disk or a memory of the computer device 8. In other embodiments, the memory 81 may be an external storage device of the computer device 8, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like provided on the computer device 8. Of course, the memory 81 may also include both internal and external storage devices of the computer device 8. In this embodiment, the memory 81 is generally used for storing an operating system and various application software installed in the computer device 8, such as program codes of a WebView-based data injection method. Further, the memory 81 may also be used to temporarily store various types of data that have been output or are to be output.
The network interface 83 may include a wireless network interface or a wired network interface, and the network interface 83 is generally used to establish communication connections between the computer device 8 and other electronic devices.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing a computer program, which is executable by at least one processor to cause the at least one processor to perform the steps of a WebView-based data injection method as described above.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method of the embodiments of the present application.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.
Claims (10)
1. A data injection method based on WebView is characterized by comprising the following steps:
acquiring a data injection request generated by a WebView terminal, and acquiring binary data corresponding to the data injection request through a Native terminal;
when the WebView end receives a uniform resource locator corresponding to the binary data, a GET request is initiated to the uniform resource locator through a browser object;
intercepting the GET request through an interceptor preset by the Native terminal, and judging whether the uniform resource locator meets a preset condition to obtain a judgment result;
if the judgment result is that the uniform resource locator meets the preset condition, the binary data is obtained by analyzing the uniform resource locator;
converting the binary data into a Web object, and returning the Web object to the WebView terminal;
and when the condition that the Web object returns to the WebView end is monitored, performing data type conversion on the Web object according to a preset data type so as to inject the binary data into the WebView end.
2. The WebView-based data injection method of claim 1, wherein the acquiring the WebView end generates a data injection request, and the acquiring the binary data corresponding to the data injection request through a Native end comprises:
acquiring the data injection request generated by the WebView terminal;
acquiring a search path corresponding to the data injection request by analyzing the data injection request;
and acquiring the binary data corresponding to the search path through the Native terminal.
3. The WebView-based data injection method of claim 1, wherein when the WebView end receives a uniform resource locator corresponding to the binary data, then initiating a GET request to the uniform resource locator through a browser object comprises:
acquiring a uniform resource locator corresponding to the binary data;
sending the uniform resource locator to the WebView terminal in a mode of calling JavaScript codes;
and when the WebView end receives the uniform resource locator, calling the browser object to initiate the GET request to the uniform resource locator.
4. The WebView-based data injection method of claim 3, wherein after said when the WebView end receives the uniform resource locator, then invoking the browser object to initiate the GET request to the uniform resource locator, the method further comprises:
responding to the type corresponding to the browser object to acquire the preset data type;
and converting the data type of the binary data into the preset data type in a traversal mode, wherein the preset data type comprises an arraybuffer type and a blob type.
5. The WebView-based data injection method of claim 1, wherein the intercepting the GET request by an interceptor preset by the Native terminal and determining whether the uniform resource locator meets a preset condition, and obtaining a determination result comprises:
intercepting the GET request through an interceptor preset by the Native terminal;
identifying a domain name corresponding to the uniform resource locator;
and performing character string matching on the domain name and the character string corresponding to the preset condition to obtain the judgment result.
6. The WebView-based data injection method according to any one of claims 1 to 5, wherein when it is monitored that the Web object returns to the WebView end, performing data type conversion on the Web object according to a preset data type, so that the binary data is injected into the WebView end comprises:
monitoring the Web object through the browser object of the WebView end;
when the condition that the Web object returns to the WebView end is monitored, acquiring the attribute of the Web object;
and performing data type conversion on the attribute of the Web object according to the preset data type by responding to the request of the browser object so as to inject the binary data into the WebView terminal.
7. A WebView-based data injection apparatus, comprising:
the binary data acquisition module is used for acquiring a data injection request generated by the WebView terminal and acquiring binary data corresponding to the data injection request through the Native terminal;
a uniform resource locator receiving module, configured to initiate a GET request to a uniform resource locator through a browser object when the WebView end receives the uniform resource locator corresponding to the binary data;
a judgment result obtaining module, configured to intercept the GET request through an interceptor preset at the Native end, and judge whether the uniform resource locator meets a preset condition, so as to obtain a judgment result;
a uniform resource locator analyzing module, configured to analyze the uniform resource locator to obtain the binary data if the determination result indicates that the uniform resource locator meets the preset condition;
the binary data conversion module is used for converting the binary data into a Web object and returning the Web object to the WebView terminal;
and the binary data injection module is used for performing data type conversion on the Web object according to a preset data type when the condition that the Web object returns to the WebView end is monitored, so that the binary data is injected into the WebView end.
8. The WebView-based data injection apparatus of claim 7, wherein said binary data acquisition module comprises:
the data injection request acquisition unit is used for acquiring the data injection request generated by the WebView terminal;
the search path acquisition unit is used for acquiring a search path corresponding to the data injection request by analyzing the data injection request;
and the search path execution unit is used for acquiring the binary data corresponding to the search path through the Native terminal.
9. A computer device comprising a memory having stored therein a computer program and a processor that, when executed, implements the WebView-based data injection method of any of claims 1 to 6.
10. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, implements the WebView-based data injection method of any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110340209.2A CN112948727B (en) | 2021-03-30 | 2021-03-30 | WebView-based data injection method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110340209.2A CN112948727B (en) | 2021-03-30 | 2021-03-30 | WebView-based data injection method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112948727A true CN112948727A (en) | 2021-06-11 |
CN112948727B CN112948727B (en) | 2024-05-14 |
Family
ID=76230513
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110340209.2A Active CN112948727B (en) | 2021-03-30 | 2021-03-30 | WebView-based data injection method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112948727B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8489676B1 (en) * | 2010-06-30 | 2013-07-16 | Symantec Corporation | Technique for implementing seamless shortcuts in sharepoint |
CN103366019A (en) * | 2013-08-06 | 2013-10-23 | 飞天诚信科技股份有限公司 | Webpage intercepting method and device based on iOS device |
CN107241408A (en) * | 2017-06-05 | 2017-10-10 | 上海鋆创信息技术有限公司 | A kind of data transmission method and device, terminal device, storage medium |
CN108124016A (en) * | 2018-01-11 | 2018-06-05 | 网宿科技股份有限公司 | A kind of method and apparatus for sending POST request |
CN109150965A (en) * | 2018-07-06 | 2019-01-04 | 百度在线网络技术(北京)有限公司 | The anti-screen method of information resources, device, computer equipment and storage medium |
CN111797020A (en) * | 2020-07-03 | 2020-10-20 | 北京每日优鲜电子商务有限公司 | Mock data method and device based on dynamic bytecode |
CN112148675A (en) * | 2020-11-24 | 2020-12-29 | 树根互联技术有限公司 | Data transmission method and device, electronic equipment and storage medium |
US20210064391A1 (en) * | 2019-08-28 | 2021-03-04 | DraftKings, Inc. | Systems and methods for in-application dynamic content loading |
-
2021
- 2021-03-30 CN CN202110340209.2A patent/CN112948727B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8489676B1 (en) * | 2010-06-30 | 2013-07-16 | Symantec Corporation | Technique for implementing seamless shortcuts in sharepoint |
CN103366019A (en) * | 2013-08-06 | 2013-10-23 | 飞天诚信科技股份有限公司 | Webpage intercepting method and device based on iOS device |
CN107241408A (en) * | 2017-06-05 | 2017-10-10 | 上海鋆创信息技术有限公司 | A kind of data transmission method and device, terminal device, storage medium |
CN108124016A (en) * | 2018-01-11 | 2018-06-05 | 网宿科技股份有限公司 | A kind of method and apparatus for sending POST request |
CN109150965A (en) * | 2018-07-06 | 2019-01-04 | 百度在线网络技术(北京)有限公司 | The anti-screen method of information resources, device, computer equipment and storage medium |
US20210064391A1 (en) * | 2019-08-28 | 2021-03-04 | DraftKings, Inc. | Systems and methods for in-application dynamic content loading |
CN111797020A (en) * | 2020-07-03 | 2020-10-20 | 北京每日优鲜电子商务有限公司 | Mock data method and device based on dynamic bytecode |
CN112148675A (en) * | 2020-11-24 | 2020-12-29 | 树根互联技术有限公司 | Data transmission method and device, electronic equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
张波等: "基于对象视图模型WebView的Web应用框架", 《软件学报》, no. 10, 23 October 2002 (2002-10-23), pages 1985 - 1990 * |
Also Published As
Publication number | Publication date |
---|---|
CN112948727B (en) | 2024-05-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10635735B2 (en) | Method and apparatus for displaying information | |
WO2017190641A1 (en) | Crawler interception method and device, server terminal and computer readable medium | |
CN106874471B (en) | Information pushing method and device | |
US20190213014A1 (en) | Method and apparatus for loading kernel module | |
US20140181262A1 (en) | Use of internet information services logging to collect user information in an asynchronous manner | |
CN107463453B (en) | Method, device, equipment and storage medium for communication between different applications of same terminal | |
CN111163095B (en) | Network attack analysis method, network attack analysis device, computing device, and medium | |
US20190222587A1 (en) | System and method for detection of attacks in a computer network using deception elements | |
WO2015074459A1 (en) | Method and apparatus for opening webpage, invoking client, and creating light app | |
CN110708335A (en) | Access authentication method and device and terminal equipment | |
CN111163094B (en) | Network attack detection method, network attack detection device, electronic device, and medium | |
US8789177B1 (en) | Method and system for automatically obtaining web page content in the presence of redirects | |
CN112416458A (en) | Preloading method and device based on ReactNative, computer equipment and storage medium | |
CN113761412A (en) | Application page display method and device, electronic equipment, medium and application system | |
JP2022546073A (en) | Connecting web publisher inventory to programmatic exchanges without third party cookies | |
CN112241298A (en) | Page display method and device, storage medium and electronic device | |
CN110808868A (en) | Test data acquisition method and device, computer equipment and storage medium | |
CN111782244A (en) | Configuration file updating method and device, computer equipment and storage medium | |
CN111666567A (en) | Detection method, device, computer program and medium for malicious modification of application program | |
US9191392B2 (en) | Security configuration | |
CN103793459B (en) | Webpage opening method and device | |
CN113315829B (en) | Client offline H5 page loading method and device, computer equipment and medium | |
CN112948727B (en) | WebView-based data injection method, device, equipment and storage medium | |
CN115733685A (en) | Web session authentication management method and device, computer equipment and storage medium | |
CN112769975B (en) | Data integration method and device, server and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |