CN112948727B - 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
- CN112948727B CN112948727B CN202110340209.2A CN202110340209A CN112948727B CN 112948727 B CN112948727 B CN 112948727B CN 202110340209 A CN202110340209 A CN 202110340209A CN 112948727 B CN112948727 B CN 112948727B
- Authority
- CN
- China
- Prior art keywords
- webview
- data
- terminal
- resource locator
- binary data
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; 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 end and acquiring binary data; when the WebView receives the uniform resource locator, initiating a GET request; intercepting a GET request through an interceptor preset by a Native terminal, judging whether the uniform resource locator accords with preset conditions, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into Web objects; when the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to the preset data type, so that binary data are injected into the WebView terminal. The present application also relates to blockchain technology in which binary data is stored. According to the application, the GET request is intercepted by the interceptor, and the binary data is converted into the Web object, so that the efficiency of injecting the binary data into the WebView terminal is improved.
Description
Technical Field
The application relates to the technical field of data acquisition, in particular to a WebView-based data injection method, a WebView-based data injection device, webView-based data injection equipment and a WebView-based storage medium.
Background
WebView is a very important component of App content presentation, and Native and WebView communication is indispensable. Most of the time, native and WebView communication interactions are not large in data volume and are 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 are injected. In some scenarios, if Native is required to inject larger binary data, such as media data like images, audio, etc.
The binary data is injected into the WebView end, the existing mode is that the binary data is firstly serialized, namely converted into a hex or base64 format, then the binary data character string is injected into the JavaScript end through the interface, and the binary data character string is decoded through the JavaScript end, so that the binary data is obtained. When the binary data is injected into a large data volume, the binary data needs to be serialized and then is decoded 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 that can enhance binary data injection into the WebView side.
Disclosure of Invention
The embodiment of the application aims to provide a data injection method, device, equipment and storage medium based on WebView, so as to improve the efficiency of binary data injection into a WebView terminal.
In order to solve the above technical problems, an embodiment of the present application provides a data injection method based on WebView, 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 receives the uniform resource locator corresponding to the binary data, initiating a GET request 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 preset conditions or not to obtain a judging result;
If the judging result shows that the uniform resource locator meets the preset condition, the binary data are obtained by analyzing the uniform resource locator;
Converting the binary data into a Web object, and returning the Web object to the WebView end;
When the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to a preset data type, so that the binary data is injected into the WebView terminal.
In order to solve the above technical problems, an embodiment of the present application provides a WebView-based data injection device, including:
The binary data acquisition module is used for acquiring a data injection request generated by a WebView terminal and acquiring binary data corresponding to the data injection request through a Native terminal;
The unified resource locator receiving module is used for initiating a GET request to the unified resource locator through a browser object when the WebView receives the unified resource locator corresponding to the binary data;
The judging result obtaining module is used for intercepting the GET request through an interceptor preset by the Native terminal, judging whether the uniform resource locator accords with preset conditions, and obtaining a judging result;
The uniform resource locator analysis module is used for obtaining the binary data by analyzing the uniform resource locator if the judging result is that the uniform resource locator accords with the preset condition;
The binary data conversion module is used for converting the binary data into Web objects and returning the Web objects to the WebView end;
And the binary data injection module is used for carrying out data type conversion on the Web object according to a preset data type when the Web object is monitored to return to the WebView terminal, so that the binary data is injected into the WebView terminal.
In order to solve the technical problems, the invention adopts a technical scheme that: a computer device is provided comprising one or more processors; and the memory is used for storing one or more programs, so that the one or more processors can realize the WebView-based data injection method.
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 which 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, device and equipment based on WebView and a storage medium. The method comprises the following steps: acquiring a data injection request generated by a WebView terminal, and acquiring binary data; when the WebView receives the uniform resource locator, initiating a GET request; intercepting a GET request through an interceptor preset by a Native terminal, judging whether the uniform resource locator accords with preset conditions, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into Web objects; when the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to the preset data type, so that binary data are injected into the WebView terminal. According to the embodiment of the invention, the GET request is intercepted by the interceptor, binary data is converted into the Web object, and finally, the Web object is subjected to data type conversion, so that the binary data is injected into the WebView end, transcoding in a JavaScript environment is not needed, and the efficiency of injecting the binary data into the WebView end is improved.
Drawings
In order to more clearly illustrate the solution of the present application, a brief description will be given below of the drawings required for the description of the embodiments of the present application, it being apparent that the drawings in the following description are some embodiments of the present application, and that other drawings may be obtained from these drawings without the exercise of inventive effort for a person of ordinary skill in the art.
FIG. 1 is a schematic view of an application environment of a WebView-based data injection method according to an embodiment of the present application;
FIG. 2 is a flowchart of an implementation of a WebView-based data injection method according to an embodiment of the present application;
FIG. 3 is a flowchart of an implementation of a sub-process of 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 of the WebView-based data injection method according to an embodiment of the present application;
FIG. 5 is a flowchart of another implementation of a sub-process of the WebView-based data injection method provided by an embodiment of the present application;
FIG. 6 is a flowchart of another implementation of a sub-process of the WebView-based data injection method provided by an embodiment of the present application;
FIG. 7 is a flowchart of another implementation of a sub-process of the 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 device according to an embodiment of the present application;
Fig. 9 is a schematic diagram of a computer device according to 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 applications herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having" and any variations thereof in the description of the application and the claims and the description of the drawings above are intended to cover a non-exclusive inclusion. The terms first, second and the like in the description and in the claims or in the above-described figures, are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases 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. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
In order to make the person skilled in the art better understand the solution of the present application, the technical solution of the embodiment 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 with reference to the drawings and embodiments.
Referring to fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as a web browser application, a search class application, an instant messaging tool, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and 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 data injection method based on WebView provided by the embodiment of the present application is generally executed by a server, and accordingly, the data injection device based on WebView 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 one embodiment of a WebView-based data injection method.
It should be noted that, if there are substantially the same results, 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 terminal, the WebView terminal generates a data injection request, and after the server acquires the data injection request, the Native terminal acquires corresponding binary data. For example, when the real-time frame data of the camera needs to be injected into the WebView end, the camera needs to be turned on and the real-time frame data needs to be acquired, the real-time frame data is sent to the Native end first, and the real-time frame data exists in the form of binary data, that is, in the form of byte arrays.
The Webview end is an engine based on webkit, can analyze DOM elements and display html page controls, and has the same principle as a browser displaying pages, so that the Webview end can be regarded as a browser. The Native terminal refers to an Android Native terminal, which is a client based on an Android system. The Androidnative end corresponds to a Native layer, which is generally developed by C++ relative to the bottom layer of the Java layer, and is deployed with common local services, link libraries and the like. In this embodiment, binary data is intercepted and converted by communication between the Native terminal and the Webview terminal, so as to inject the binary data into the Webview terminal.
Referring to fig. 3, fig. 3 shows a specific implementation manner of step S1, and this embodiment 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: binary data corresponding to the search path is obtained through the Native terminal.
Specifically, since the data injection request generated by the WebView end has different data sources and different stored paths, the data injection request needs to be analyzed, and different types of data requests are distinguished through a Path function, namely, the search Path corresponding to the data injection request is acquired. And obtaining corresponding binary data according to the search path.
The Path function is a DOS (disk operating system) Path setting command, and the Path function is a search Path of an executable file of the equipment, when one executable file is operated, the DOS searches the current catalog for the file, and if the executable file is found, the DOS operates; if the file cannot be found, the file is searched in the directory sequentially and piece by piece according to the Path set by the Path function. The search path is a path for storing or querying the corresponding data of the data injection request. For example, if the data corresponding to the data injection request is the real-time frame data of the request camera, the generated uniform resource locator is http:// pamina. And if the real-time recording data is requested, setting the uniform resource locator as' http:// pamina.
In the implementation, the corresponding search path is obtained by analyzing the data injection request, and binary data is obtained according to the search path, so that different data injection requests are distinguished, the corresponding binary data is obtained quickly, and the efficiency of binary injection of the WebView terminal is improved.
S2: when the WebView 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 above steps have acquired binary data at the Native terminal, but the binary data has not yet been able to be sent to the WebView terminal. Therefore, a uniform resource locator corresponding to binary data needs to be generated at the Native terminal, the uniform resource locator is sent to the WebView terminal, the WebView terminal is informed of new binary data generation, and therefore 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 a browser object.
Wherein the browser object refers to XMLHttpRequest, and XMLHttpRequest (XHR) is an Application Program Interface (API) object, and the method can be used for transmitting data between the browser and the server. This object is provided by the JavaScript environment of the browser. The purpose of retrieving data from XMLHttpRequest is to continually modify a loaded page, which is the underlying concept of the Ajax design. The protocol used by XMLHttpRequest is different from HTTP, not only XML format data can be used, but JSON, HTML or plain text is 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.
Wherein the GET request is a request to send data to the server. In the embodiment of the application, the browser object initiates the GET request to the uniform resource locator, so that the WebView end initiates the request for acquiring the binary data.
Referring to fig. 4, fig. 4 shows a specific implementation manner of step S2, and this embodiment includes:
s21: and acquiring a uniform resource locator corresponding to the binary data.
S22: and sending the uniform resource locator to the WebView terminal by calling JavaScript code.
Specifically, binary data is obtained at the Native terminal, and a uniform resource locator corresponding to the binary data is generated. In order to reduce the data size and improve the transmission efficiency, a uniform resource locator is sent to the WebView terminal by calling JavaScript codes, so that the WebView terminal can be informed of new binary data generation at the Native terminal.
The method for calling the JavaScript code is to inject the JavaScript code into the JavaScript code through evaluateJavascript, so that the uniform resource locator is sent to the WebView terminal.
S23: when the WebView receives the uniform resource locator, then the browser object is invoked to initiate a GET request to the uniform resource locator.
Specifically, the unified resource locator is received at the WebView end in the form of calling JavaScript codes. And at the WebView end, a browser object, namely a method in XMLHttpRequest, is called, so that a GET request is initiated to the uniform resource locator.
In the implementation, the JavaScript code is called to send the binary data to the WebView terminal, and the GET request is initiated at the WebView terminal, so that the binary data acquisition request is initiated at the WebView terminal, the subsequent injection of the binary data to the WebView terminal is facilitated, and the efficiency of the binary data injection to the WebView terminal is improved.
Referring to fig. 5, fig. 5 shows a specific implementation manner after step S23, and this embodiment includes:
s231: responding to the corresponding type of the browser object to obtain the preset data type.
S232: and converting the data type of the binary data into a preset data type by adopting a traversing mode, wherein the preset data type comprises arraybuffer types and blob types.
Specifically, in the embodiment of the present application, the type corresponding to the response browser object refers to a response xmlhttprequest.responsetype function, where the attribute corresponding to the xmlhttprequest.responsetype function is an attribute of an enumeration type, and can return a type of response data. It allows us to manually set the type of returned data. If it is set to an empty string, it will use the default "text" type. In the embodiment of the application, the preset data type is obtained by responding to the XMLHttpRequest.responseType function, and then binary data is converted into the corresponding data conversion type according to the traversing mode.
The preset data types are set according to actual conditions and comprise arraybuffer types and blob types. arraybuffer types refer to typed arrays. The blob type refers to a blob, which is a container in which binary files may be stored.
In the embodiment, the preset data type is obtained by responding to the corresponding type of the browser object, and the data type of the binary data is converted into the preset data type in a traversing mode, so that the binary data is converted into the corresponding type, and the binary data can be conveniently identified later.
S3: intercepting the GET request through an interceptor preset by the Native terminal, and judging whether the uniform resource locator meets preset conditions or not to obtain a judging result.
Specifically, an interceptor is preset at the Native terminal, after a GET request is initiated at the WebView terminal, the GET request is intercepted, and whether a uniform resource locator corresponding to the GET request meets preset conditions is judged, so that a judgment result is obtained.
The preset condition is a character string set according to the suffix of the domain name, and is used for distinguishing whether the domain name corresponding to the uniform resource locator meets the requirement. For example, the preset condition is "com", if the domain name in the uniform resource locator has a character matching with "com", the judgment 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 the interceptor preset at the Native terminal, an interceptor is preset at the Native terminal. The preset Interceptor is preset with a class realizing the Interceptor interface or inherits abstract class AbstractInterceptor, registers the defined Interceptor in the configuration file, and references the defined Interceptor when the intercepting function is needed. In the embodiment of the application, the interceptor defined by registering in the configuration file can set the intercepted domain name, such as pamina.
Referring to fig. 6, fig. 6 shows a specific implementation manner of step S3, and this embodiment includes:
s31: and intercepting the GET request through an interceptor preset by the Native terminal.
S32: and identifying the domain name corresponding to the uniform resource locator.
S33: and carrying out character string matching on the domain name and the character string corresponding to the preset condition to obtain a judging result.
Specifically, when an interceptor preset by the Native terminal recognizes that the WebView terminal initiates the GET request, the GET request is intercepted. And acquiring the uniform resource locator corresponding to the GET request, thereby identifying the domain name corresponding to the uniform resource locator, judging whether the domain name meets the preset condition, and further achieving the judgment result.
The Domain Name (Domain Name), also called network Domain, is the Name of a computer or a computer group on the Internet, which is formed by a series of names separated by dots, and is used for locating and identifying the computer during data transmission.
Specifically, since the domain name has domain name suffixes of ". Com", ". Net", ". Cn", ". Edu", ". Top", ". Xyz", and the like. The preset conditions can set 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 conditions, the judgment result is that the domain name accords with the preset conditions, otherwise, the domain name does not accord with the preset conditions.
In the implementation, the GET request is intercepted by the interceptor preset by the Native terminal, the domain name corresponding to the uniform resource locator is identified, and then the character string matching is carried out on the domain name and the character string corresponding to the preset condition, so that a judgment result is obtained, the GET request interception and the judgment result acquisition are realized, the corresponding binary data is favorably sent to the WebView terminal, and the efficiency of binary data injection to the WebView terminal is favorably improved.
S4: and if the judging result is that the uniform resource locator meets the preset condition, obtaining binary data by analyzing the uniform resource locator.
Specifically, if the suffix in the domain name corresponding to the uniform resource locator is matched with the character string in the preset condition, the judgment result is that the uniform resource locator meets the preset condition. And analyzing the uniform resource locator to obtain a binary data corresponding path, thereby obtaining the binary data.
S5: converting the binary data into Web objects, and returning the Web objects to the WebView terminal.
Specifically, the Web object refers to WebResourceResponse objects, which refer to response information that encapsulates a Web resource, where the response information of the Web resource includes: responsive to 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 WebResourceResponse objects through the eval () function of JavaScript. The eval () function uses a JavaScript compiler, which can parse JSON text and then generate WebResourceResponse objects. The Web object is then returned to the WebView side.
S6: when the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to the preset data type, so that binary data are injected into the WebView terminal.
Specifically, when the browser object at the WebView end monitors that the Web object returns, that is, monitors that the Web object returns through XMLHttpReques, the attribute of the Web object is obtained, and the attribute of the Web object is converted into the corresponding data type according to the preset data type, so that binary data is injected into the WebView end.
In this embodiment, the data injection request generated by the WebView end is obtained, and binary data is obtained; when the WebView receives the uniform resource locator, initiating a GET request; intercepting a GET request through an interceptor preset by a Native terminal, judging whether the uniform resource locator accords with preset conditions, and if so, analyzing the uniform resource locator to obtain binary data; converting binary data into Web objects; when the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to the preset data type, so that binary data are injected into the WebView terminal. According to the embodiment of the invention, the GET request is intercepted by the interceptor, binary data is converted into the Web object, and finally, the Web object is subjected to data type conversion, so that the binary data is injected into the WebView end, transcoding in a JavaScript environment is not needed, and the efficiency of injecting the binary data into the WebView end is improved.
Referring to fig. 7, a specific implementation manner of step S6 is illustrated, and this embodiment includes:
s61: and monitoring the Web object through the browser object at the WebView end.
S62: when the Web object is monitored to return to the WebView end, the attribute of the Web object is acquired.
S63: and converting the data type of the attribute of the Web object according to the preset data type by responding to the request of the browser object, so that binary data is injected 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. Responding to a request by a browser object is accomplished by xmlhttprequest. The type of return may be one of arraybuffer, blob, document, javaScript Object, or DOMString. In the embodiment of the present application, since the preset data types include: arraybuffer type, blob type, then the data can be returned as arraybuffer type or blob type by responding to the browser object's request.
In the implementation, the Web object is monitored through the browser object of the WebView terminal, the attribute of the Web object is obtained, and the attribute of the Web object is subjected to data type conversion according to the preset data type by responding to the request of the browser object, so that binary data is injected into the WebView terminal, and finally, the binary data is injected 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 nodes of a blockchain.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored in a computer-readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. The storage medium may be a nonvolatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a random access Memory (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 device, which corresponds to the embodiment of the method shown in fig. 2, and the device may be applied to various electronic devices.
As shown in fig. 8, the WebView-based data injection device of the present embodiment includes: the system comprises an item identification acquisition module 71, a configuration file selection module 72, a target version branching module 73, a warehouse source code pulling module 74, a judgment result acquisition module 75 and a successful item construction module 76, wherein:
The binary data acquisition module 71 is configured to acquire a data injection request generated by the WebView terminal, and acquire binary data corresponding to the data injection request through the Native terminal;
A url receiving module 72, configured to initiate a GET request to the url through the browser object when the WebView receives the url corresponding to the binary data;
the judging result obtaining module 73 is configured to intercept the GET request through an interceptor preset by the Native terminal, and judge whether the uniform resource locator meets a preset condition, so as to obtain a judging result;
A uniform resource locator parsing module 74, configured to parse the uniform resource locator to obtain binary data if the determination result indicates that the uniform resource locator meets the preset condition;
The binary data conversion module 75 is used for converting binary data into Web objects and returning the Web objects to the WebView terminal;
And the binary data injection module 76 is configured to perform data type conversion on the Web object according to a preset data type when the Web object is monitored to return to the WebView terminal, so that binary data is injected into the WebView terminal.
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 the 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 binary data;
the unified resource locator sending unit is used for sending the unified 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 to initiate a GET request to the uniform resource locator when the WebView receives the uniform resource locator.
Further, after the browser object calling unit, the WebView-based data injection device further includes:
the preset data type conversion unit is used for responding to the corresponding type of the browser object to obtain a preset data type;
The binary data conversion unit is used for converting the data type of binary data into a preset data type in a traversing mode, wherein the preset data type comprises arraybuffer types and blob types.
Further, the judgment result acquisition module 73 includes:
the GET request interception unit is used for intercepting the GET request through an interceptor preset by the Native terminal;
The domain name identification unit is used for identifying the domain name corresponding to the uniform resource locator;
And the character string matching unit is used for carrying out character string matching on the domain name and the character string corresponding to the preset condition to obtain a judging result.
Further, the binary data injection module 76 includes:
the Web object monitoring unit is used for monitoring the Web object through the browser object at the WebView end;
The data type acquisition unit is used for acquiring the attribute of the Web object when the Web object is monitored to return to the WebView end;
the data injection unit is used for responding to the request of the browser object, converting the attribute of the Web object into the data type according to the preset data type, and injecting 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 nodes of a blockchain.
In order to solve the technical problems, the embodiment of the application also provides computer equipment. Referring specifically to fig. 9, fig. 9 is a basic structural block diagram of a computer device according to the present embodiment.
The computer device 8 comprises a memory 81, a processor 82, a network interface 83 communicatively connected to each other via a system bus. It should be noted that only a computer device 8 having three components memory 81, a processor 82, a network interface 83 is shown in the figures, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead. It will be appreciated by those skilled in the art that the computer device herein is a device capable of automatically performing numerical calculations and/or information processing according to predetermined or stored instructions, and the hardware thereof includes, but is not limited to, microprocessors, application specific integrated circuits (ApplicationSpecific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable GATE ARRAY, FPGA), digital processors (DIGITAL SIGNAL processors, DSPs), embedded devices, and the like.
The computer device may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The computer device can perform man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch pad or voice control equipment and the like.
The memory 81 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), programmable Read Only Memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 81 may be an internal storage unit of the computer device 8, such as a hard disk or memory of the computer device 8. In other embodiments, the memory 81 may also be an external storage device of the computer device 8, such as a plug-in hard disk provided on the computer device 8, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD), or the like. Of course, the memory 81 may also include both internal storage units of the computer device 8 and external storage devices. In this embodiment, the memory 81 is generally used to store an operating system and various types of application software installed on the computer device 8, such as program codes of a WebView-based data injection method. Further, the memory 81 may be used to temporarily store various types of data that have been output or are to be output.
The processor 82 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 82 is typically used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is configured to execute the program code stored in the memory 81 or process data, for example, execute the program code of the above-mentioned WebView-based data injection method, so as to implement various embodiments of the WebView-based data injection method.
The network interface 83 may comprise a wireless network interface or a wired network interface, which network interface 83 is typically used to establish a communication connection between the computer device 8 and other electronic devices.
The present application also provides another embodiment, namely, a computer readable storage medium, where a computer program is stored, where the computer program is executable by at least one processor, so that the at least one processor performs the steps of a WebView-based data injection method as described above.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method of the embodiments of the present application.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The blockchain (Blockchain), essentially a de-centralized database, is a string of data blocks that are generated in association using cryptographic methods, each of which contains information from a batch of network transactions for verifying the validity (anti-counterfeit) of its information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
It is apparent that the above-described embodiments are only some embodiments of the present application, but not all embodiments, and the preferred embodiments of the present application are shown in the drawings, which do not limit the scope of the patent claims. This application may be embodied in many different forms, but rather, embodiments are provided in order to provide a thorough and complete understanding of the present disclosure. Although the application has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that modifications may be made to the embodiments described in the foregoing description, or equivalents may be substituted for elements thereof. All equivalent structures made by the content of the specification and the drawings of the application are directly or indirectly applied to other related technical fields, and are also within the scope of the application.
Claims (9)
1. The data injection method based on WebView is characterized by comprising the following steps of:
Acquiring a data injection request generated by a WebView terminal, and acquiring binary data corresponding to the data injection request through a Native terminal;
acquiring a uniform resource locator corresponding to the binary data;
Transmitting a uniform resource locator to the WebView terminal by calling JavaScript codes;
When the WebView receives the uniform resource locator, invoking a browser object to initiate a GET request to the uniform resource locator;
Intercepting the GET request through an interceptor preset by the Native terminal, and judging whether the uniform resource locator meets preset conditions or not to obtain a judging result;
If the judging result shows that the uniform resource locator meets the preset condition, the binary data are obtained by analyzing the uniform resource locator;
Converting the binary data into a Web object, and returning the Web object to the WebView end;
When the Web object is monitored to return to the WebView terminal, the Web object is subjected to data type conversion according to a preset data type, so that the binary data is injected into the WebView terminal.
2. The WebView-based data injection method of claim 1, wherein the obtaining the WebView terminal generates a data injection request, and obtaining the binary data corresponding to the data injection request through a Native terminal includes:
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 after invoking the browser object to initiate the GET request to the uniform resource locator when the WebView receives the uniform resource locator, the method further comprises:
Responding to the corresponding type of the browser object to acquire the preset data type;
and converting the data type of the binary data into the preset data type by adopting a traversing mode, wherein the preset data type comprises arraybuffer type and blob type.
4. The WebView-based data injection method of claim 1, wherein the intercepting the GET request by the interceptor preset by the Native terminal and determining whether the uniform resource locator meets a preset condition, and obtaining a determination result includes:
intercepting the GET request through an interceptor preset by the Native terminal;
Identifying a domain name corresponding to the uniform resource locator;
And carrying out character string matching on the domain name and the character string corresponding to the preset condition to obtain the judging result.
5. The WebView-based data injection method according to any one of claims 1 to 4, wherein when the Web object is monitored to return to the WebView terminal, performing data type conversion on the Web object according to a preset data type, so that the binary data is injected into the WebView terminal includes:
Monitoring the Web object through the browser object of the WebView terminal;
when the Web object is monitored to return to the WebView end, acquiring the attribute of the Web object;
and responding to the request of the browser object, and performing data type conversion on the attribute of the Web object according to the preset data type so as to enable the binary data to be injected into the WebView terminal.
6. A WebView-based data injection device, comprising:
The binary data acquisition module is used for acquiring a data injection request generated by a WebView terminal and acquiring binary data corresponding to the data injection request through a Native terminal;
a uniform resource locator obtaining unit, configured to obtain a uniform resource locator corresponding to the binary data;
The unified resource locator sending unit is used for sending the unified resource locator to the WebView terminal in a mode of calling JavaScript codes;
A browser object calling unit, configured to call a browser object to initiate a GET request to the uniform resource locator when the WebView receives the uniform resource locator;
The judging result obtaining module is used for intercepting the GET request through an interceptor preset by the Native terminal, judging whether the uniform resource locator accords with preset conditions, and obtaining a judging result;
The uniform resource locator analysis module is used for obtaining the binary data by analyzing the uniform resource locator if the judging result is that the uniform resource locator accords with the preset condition;
The binary data conversion module is used for converting the binary data into Web objects and returning the Web objects to the WebView end;
And the binary data injection module is used for carrying out data type conversion on the Web object according to a preset data type when the Web object is monitored to return to the WebView terminal, so that the binary data is injected into the WebView terminal.
7. The WebView-based data injection device of claim 6, wherein the binary data acquisition module includes:
a data injection request acquisition unit, configured to acquire the data injection request generated by the WebView end;
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.
8. A computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the WebView-based data injection method of any of claims 1 to 5 when the computer program is executed.
9. A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, which when executed by a processor implements the WebView-based data injection method of any of claims 1 to 5.
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 CN112948727A (en) | 2021-06-11 |
CN112948727B true 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) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117194830A (en) * | 2023-05-25 | 2023-12-08 | 北京陌陌信息技术有限公司 | Method, device and storage medium for accessing local file based on WebView |
Citations (7)
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 |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11392394B2 (en) * | 2019-08-28 | 2022-07-19 | 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 (7)
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 |
Non-Patent Citations (1)
Title |
---|
基于对象视图模型WebView的Web应用框架;张波等;《软件学报》;20021023(第10期);第1985-1990页 * |
Also Published As
Publication number | Publication date |
---|---|
CN112948727A (en) | 2021-06-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10635735B2 (en) | Method and apparatus for displaying information | |
US10003671B2 (en) | Capturing and replaying application sessions using resource files | |
US9444899B2 (en) | Use of internet information services logging to collect user information in an asynchronous manner | |
CN113315829B (en) | Client offline H5 page loading method and device, computer equipment and medium | |
WO2016173200A1 (en) | Malicious website detection method and system | |
CN113536185B (en) | Application page loading method, storage medium and related equipment | |
CN109672658B (en) | JSON hijacking vulnerability detection method, device, equipment and storage medium | |
CN112596932B (en) | Service registration and interception method, device, electronic device and readable storage medium | |
CN108416021B (en) | Browser webpage content processing method and device, electronic equipment and readable medium | |
CN110808868B (en) | Test data acquisition method and device, computer equipment and storage medium | |
CN113761412A (en) | Application page display method and device, electronic equipment, medium and application system | |
WO2015074459A1 (en) | Method and apparatus for opening webpage, invoking client, and creating light app | |
CN108494762A (en) | Web access method, device and computer readable storage medium, terminal | |
CN113076294B (en) | Information sharing method and device | |
CN116304458B (en) | Method, device, equipment and medium for web page real-time notification update | |
CN111291288B (en) | Webpage link extraction method and system | |
JP5604016B1 (en) | Script caching method and information processing apparatus using the same | |
JP5039946B2 (en) | Technology for relaying communication between client devices and server devices | |
CN112948727B (en) | WebView-based data injection method, device, equipment and storage medium | |
CN111797297A (en) | Page data processing method and device, computer equipment and storage medium | |
CN109246069B (en) | Webpage login method and device and readable storage medium | |
CN115525305A (en) | Data processing method, application starting method, device, computer equipment and storage medium | |
CN112000313A (en) | Request response method, device, equipment and storage medium | |
CN111193729A (en) | Cross-terminal user identity recognition method and device and computer readable storage medium | |
CN105282150A (en) | Log-in assistant system for Web system |
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 |