Disclosure of Invention
An object of the present disclosure is to provide a method, an apparatus, an electronic device, and a computer-readable storage medium for acquiring web page resources, thereby overcoming, at least to some extent, one or more of the problems due to the limitations and disadvantages of the related art.
According to one aspect of the present disclosure, a method for acquiring web page resources is provided, including:
responding to access of a user triggered application program APP associated webpage, and acquiring access parameters of the APP associated webpage;
adding the access parameter into header information of an access request instruction, and sending the access request instruction to a webpage server through a preset access path;
and receiving the rendered webpage information generated by the webpage server according to the head information, loading the webpage information, and calling a display interface to display the loaded webpage information.
In an exemplary embodiment of the present disclosure, the method includes:
after the webpage information after the rendering processing is obtained, sending communication request information to a webpage server according to a preset data transmission rule;
receiving communication response information returned by the webpage server;
when the current version is determined to be the unsupported version, sending update information for updating the webpage parameters to the webpage server so that the webpage server refreshes the webpage and clears webpage cache;
and when the current version is determined to be the supported version, generating APP environment parameters, and sending a first callback function containing the APP environment parameters according to the preset data transmission rule, so that the webpage server correspondingly updates data according to the first callback function.
In an exemplary embodiment of the present disclosure, the communication request information includes version number information, and after receiving the communication request information sent by the web server according to a preset data transfer rule, the method further includes:
and determining whether the current version is a supportable version or not according to the version number information. In an exemplary embodiment of the present disclosure, the sending, to the web server, communication request information including a preset method delivery parameter includes:
and periodically polling according to a preset data transmission rule to send communication request information to the webpage server.
In an exemplary embodiment of the present disclosure, the method includes:
receiving a first operation instruction triggered by a user webpage access operation, confirming whether an object webpage of the user webpage access operation is an independent webpage, if not, acquiring APP environment parameters, judging whether the current webpage is in the APP environment according to the APP environment parameters, if determining that the current webpage is not in the APP environment, executing the step of adding the access parameters into header information of an access request instruction, and sending the access request instruction to a webpage server through a preset access path.
In an exemplary embodiment of the present disclosure, the method includes:
if the first operation instruction triggered by the webpage access operation of the user is determined to be a specified operation instruction, generating a link opening parameter and initiating an external access request;
after receiving external response information replied according to the external access request, outputting corresponding webpage information through the external access request; and if the external response information is not received in a preset waiting period, skipping the current output page to an APP download page.
In an exemplary embodiment of the present disclosure, the method includes:
when a second operation instruction triggered by the operation of the user on the APP is monitored, a second callback function corresponding to the second operation instruction is sent according to the preset data transfer rule, and after the APP calls the second callback function, the instruction corresponding to the second callback function is processed and executed.
In an exemplary embodiment of the present disclosure, the access parameter includes check information, and the method further includes:
and after the access parameters are encrypted according to the verification information in a preset encryption mode, the encryption parameters are added into the head information of the access request instruction and sent to the webpage server, so that the webpage server decrypts the access request instruction according to the verification information.
In one aspect of the present disclosure, there is provided a web page resource acquiring apparatus, including:
the acquisition module is used for responding to the access of the APP associated webpage of the user trigger application program and acquiring the access parameter of the APP associated webpage;
the sending module is used for adding the access parameters into an access request instruction and sending the access request instruction to a webpage server through a preset access path;
the receiving module is used for receiving the webpage information after the rendering processing generated by the webpage server according to the access request instruction;
and the display module is used for loading the webpage information and calling a display interface to display the loaded webpage information.
In one aspect of the present disclosure, there is provided an electronic device including:
a processor; and
a memory having computer readable instructions stored thereon which, when executed by the processor, implement a method according to any of the above.
In an aspect of the disclosure, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, realizes the method according to any one of the above.
The webpage resource obtaining method in the exemplary embodiment of the disclosure responds to the access of a user triggered application program APP associated webpage, and obtains the access parameter of the APP associated webpage; adding the access parameter into header information of an access request instruction, and sending the access request instruction to a webpage server through a preset access path; receiving rendered webpage information generated by the webpage server according to the access request instruction; and loading the webpage information, and calling a display interface to display the loaded webpage information. On one hand, the method and the device establish dynamic data connection between the APP and the webpage and achieve dynamic response between the APP and the webpage. On the other hand, the method and the device can support the acquisition of native webpages of different APP versions, and are convenient for subsequent iteration.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The same reference numerals denote the same or similar parts in the drawings, and thus, a repetitive description thereof will be omitted.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the embodiments of the disclosure can be practiced without one or more of the specific details, or with other methods, components, materials, devices, steps, and so forth. In other instances, well-known structures, methods, devices, implementations, materials, or operations are not shown or described in detail to avoid obscuring aspects of the disclosure.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in the form of software, or in one or more software-hardened modules, or in different networks and/or processor devices and/or microcontroller devices.
In the embodiment of the present invention, firstly, a method for acquiring a web page resource is provided; referring to fig. 1, the method for acquiring web page resources may include the following steps:
step S110, responding to the access of the APP associated webpage of the user triggered application program, and acquiring the access parameter of the APP associated webpage;
step S120, adding the access parameter into header information of an access request instruction, and sending the access request instruction to a webpage server through a preset access path;
step S130, receiving the rendered webpage information generated by the webpage server according to the header information, loading the webpage information, and calling a display interface to display the loaded webpage information.
The webpage resource obtaining method in the exemplary embodiment of the disclosure responds to the access of a user triggered application program APP associated webpage, and obtains the access parameter of the APP associated webpage; adding the access parameter into an access request instruction, and sending the access request instruction to a webpage server through a preset access path; and receiving the rendered webpage information generated by the webpage server according to the head information, loading the webpage information, and calling a display interface to display the loaded webpage information. On one hand, the method and the device establish dynamic data connection between the APP and the webpage and achieve dynamic response between the APP and the webpage. On the other hand, the method and the device can support the acquisition of native webpages of different APP versions, and are convenient for subsequent iteration.
Next, please refer to fig. 2 to further explain the web page resource obtaining method in the exemplary embodiment.
In step S110, in response to the user triggering access of the APP-associated webpage of the application program, access parameters of the APP-associated webpage may be acquired.
In the exemplary embodiment, the APP and the webpage agree in advance on a unified parameter format and a data transmission rule, and configure version numbers supported by the APP and the webpage respectively; the unified parameter format may include a plurality of formats of corresponding instructions, for example, the following formats of a plurality of instructions may be included:
1) initiating APP native operation through the transmission parameters;
2) after initiating APP native operation through the transfer parameter, executing the native operation and transferring a callback parameter to a webpage;
3) after the APP native operation is initiated through the transmission parameters, the APP native operation is hoisted after the native operation is executed, and the like.
Correspondingly, when the APP subsequently transmits the callback response parameter, the APP can still adopt a pre-agreed unified parameter format and a data transmission rule to return, so that the communication reliability of the two parties is ensured.
In the exemplary embodiment, when the user triggers the application program to associate with the webpage, the user may trigger the application program to associate with the webpage through various ways, for example, triggering function interaction in the APP that has been downloaded by the client, or triggering through an external sharing link, and the like. The APP associated webpages can be multiple according to actual needs, when a User accesses the native page of a certain webpage associated with the APP through the APP, the access path corresponding to the native page of the APP associated webpage and the access parameters can be obtained, and the access parameters can include a User identification token, APP version information, equipment id (identity document), check parameters, User Agent parameters User-Agent and the like.
In step S120, the access parameter may be added to an access request instruction, and the access request instruction is sent to the web server through a preset access path.
In the exemplary embodiment, besides the access request instruction including the data request information to be requested, the access parameter may be added to a field of header information of the access request instruction for transmission to improve communication efficiency. The web server is a device for providing corresponding web data service for the associated web page accessed by the user. The webpage server and the APP are matched with version number information supported by the webpage server and the APP, and the APP version information in the access parameters comprises an APP version number and is used for enabling the webpage server to be matched with a corresponding version when the parameters are transmitted to the webpage server so as to be suitable for the compatibility of an old version during version iteration; and the verification information is used for decrypting the access request instruction by the webpage server according to the verification information. And after the access parameters are encrypted according to the verification information in a preset encryption mode, the encryption parameters are added into the head information of the access request instruction and sent to the webpage server, so that the webpage server decrypts the access request instruction according to the verification information.
The preset access path is a pre-stored URL (uniform resource locator) of the associated web page, and sends an access request instruction to the web server by analyzing the URL and the address of the web server. After receiving the access request instruction, the web server combines the access parameter with other request parameters required by the web page, acquires the web page data through the request interface, and loads the corresponding execution script version according to the version number of the APP to perform the step of rendering the web page in the step S130.
In step S130, the rendered webpage information generated by the webpage server according to the header information may be received, the webpage information may be loaded, and a display interface may be invoked to display the loaded webpage information.
In the exemplary embodiment, the APP may load a web page in a Webview manner, and may embed an associated web page in the APP by transferring a web page path. After the associated webpage is loaded, the script scheme injected by the APP can be executed, and the script scheme can be called in real time when the webpage is opened, so that when the APP needs to perform certain operations through the webpage, the webpage is called to execute corresponding operations. Because the script scheme injected by the APP includes the character string, the character string needs to be transmitted after being encrypted by base64 for security, and after receiving the encrypted character string, the webpage first performs decryption by base64 to further execute the corresponding action.
In the exemplary embodiment, data is dynamically transmitted between an APP and a webpage, so that a relevant situation of a user needs to be monitored in real time, when one side changes, the other side responds synchronously, and meanwhile, when the APP and the webpage dynamically transmit data, the APP can initiate a relevant function of the webpage, and the webpage can also call a native relevant function of the APP; whether the current version is a supportable version or not can be determined according to the version number information, and when the current version is determined to be an unsupported version according to the version number information, update information for updating webpage parameters is sent to the webpage server so that the webpage server refreshes the webpage and clears webpage cache; and when the current version is determined to be the supported version according to the version number information, generating APP environment parameters, and sending a first callback function containing the APP environment parameters according to the preset data transmission rule, so that the webpage server correspondingly updates data according to the first callback function.
Specifically, a request for obtaining the APP environment parameters is initiated to the APP by the webpage server, and a timing communication mechanism is established with the APP. When a webpage server calls a data transfer rule provided by an APP to transfer communication request information, instruction parameters, APP version information and the like carried in the communication request information, after the APP receives the instruction parameters and the APP version information provided by the webpage, the instruction parameters are processed, the version number transferred by the webpage is checked, for unsupported versions, the APP generates and executes the operation of refreshing the webpage, webpage cache is cleaned, for supported versions, the APP environment parameters of the APP are obtained to generate a first callback function, so that the webpage server correspondingly updates data according to the first callback function, wherein the first callback function is a callback function for updating the data. Once the webpage server monitors that the first callback function is triggered, acquiring a first callback function returned by the APP, and when the APP returns a normal result, storing result data for simulating the request mode of the APP and transmitting the result data when the APP interacts with a rear-end interface every time, so that the rear end can return the result data consistent with the direct request rear end of the APP; and when the APP returns the page to be refreshed, the webpage refreshes the page or requests a new webpage address according to the result returned by the APP.
Further, after storing normal data, the web page may further include: and sending communication request information to the webpage server by periodically polling according to a preset data transmission rule, and refreshing and storing a returned result.
In the exemplary embodiment, a first operation instruction triggered by a user webpage access operation is received, whether a target webpage of the user webpage access operation is an independent webpage or not is confirmed, if not, an APP environment parameter is obtained, whether the target webpage is in the APP environment or not is judged according to the APP environment parameter, if the target webpage is determined not to be in the APP environment, the step of adding the access parameter to header information of an access request instruction is executed, and the access request instruction is sent to a webpage server through a preset access path. If the first operation instruction triggered by the webpage access operation of the user is determined to be a specified operation instruction, generating a link opening parameter and initiating an external access request; after receiving external response information replied according to the external access request, outputting corresponding webpage information through the external access request; and if the external response information is not received in a preset waiting period, skipping the current output page to an APP download page.
When the page of the APP has the sharing function, the APP configures the sharing link, the user shares the page according to the sharing link configured by the APP, and the user respectively processes the page after opening the page, wherein the first operation instruction is an operation of opening the sharing link. The sharing link can be an independent webpage or a non-independent webpage, when the sharing link is an independent webpage, a user accesses the sharing link process and refers to the prior art, however, when the sharing link is a non-independent webpage, namely a webpage and an APP shared page, when the user accesses the sharing link, the user firstly obtains an APP environment parameter, judges whether the sharing link is currently in an APP environment or not according to the APP environment parameter, when the sharing link is not in the APP environment, adds the access parameter into header information of an access request instruction, and sends the access request instruction to a webpage server through a preset access path; if the first operation instruction triggered by the operation of accessing the webpage by the user is determined to be a specified operation instruction, such as an instruction for accessing APP and webpage common content, a link opening parameter is generated, an external access request, namely a request for accessing an external webpage is initiated, and after external response information replied according to the external access request is received, corresponding webpage information is output; and if the external response information is not received in a preset waiting period (such as 1S), skipping the current output page to an APP downloading page, and prompting a user to download the corresponding APP.
When the user stays too long, the change of the webpage needs to be monitored dynamically, and the webpage is refreshed in real time according to the change, so that when the webpage changes dynamically, the APP content also changes dynamically. For some native basic pages in the APP, when the function of the conversion logic is refreshed in real time, the relevant information needs to be dynamically processed without perception under the condition that a user accesses the native basic pages by virtue of the dynamic realization of the webpage. Therefore, in the present exemplary embodiment, the method further includes: when a second operation instruction triggered by the operation of the user on the APP is monitored, a second callback function corresponding to the second operation instruction is sent according to the preset data transfer rule, and after the APP calls the second callback function, the instruction corresponding to the second callback function is processed and executed. .
The second operation instruction is an operation of the user on the APP function, for example: after a user opens a new webpage, returning to the old webpage when the user returns back operation, wherein the operation is mainly whether the user can share the new webpage or not; or calling a data transmission rule provided by the APP, wherein the data transmission rule depends on a specific installation package, and each new installation package inherits the old installation package so as to call a webpage; or opening a native page of the APP, such as returning to the first page, opening a new native payment page, and the like; still alternatively, the user action triggers the initiation of a native component, such as some editor, a picture magnifier, and the like.
When monitoring the operation of the user on the APP function, the webpage calls the data transmission rule provided by the APP to transmit the APP response parameter, the APP receives the APP response parameter provided by the webpage, processes the APP response parameter, and executes the corresponding instruction. And when the APP response parameters contain the second callback function, returning corresponding parameters and data, and calling the data transmission rule provided by the webpage to transmit the data. And after the webpage monitors the call of the second callback function, processing related subsequent operations according to the returned corresponding parameters and data. And monitoring user operation in real time, and repeating the operation once a second operation instruction is monitored until the webpage is closed.
It should be noted that although the various steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that these steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
In addition, in the present exemplary embodiment, a web page resource obtaining apparatus is also provided. Referring to fig. 3, the web resource acquiring apparatus 300 may include: an acquisition module 310, a sending module 320, a receiving module 330, and a display module 340. Wherein:
the obtaining module 310 is configured to obtain an access parameter of an APP-associated webpage in response to a user triggering access of the APP-associated webpage of an application;
a sending module 320, configured to add the access parameter to header information of an access request instruction, and send the access request instruction to a web server through a preset access path;
a receiving module 330, configured to receive rendered web page information generated by the web page server according to the header information;
the display module 340 is configured to load the webpage information and call a display interface to display the loaded webpage information.
The specific details of each web resource acquisition device module are already described in detail in the corresponding web resource acquisition method, and therefore are not described herein again.
It should be noted that although several modules or units of the web page resource acquisition apparatus 200 are mentioned in the above detailed description, such division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or program product. Thus, various aspects of the invention may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 400 according to such an embodiment of the invention is described below with reference to fig. 4. The electronic device 400 shown in fig. 4 is only an example and should not bring any limitation to the function and the scope of use of the embodiments of the present invention.
As shown in fig. 4, electronic device 400 is embodied in the form of a general purpose computing device. The components of electronic device 400 may include, but are not limited to: the at least one processing unit 410, the at least one memory unit 420, a bus 430 connecting different system components (including the memory unit 420 and the processing unit 410), and a display unit 440.
Wherein the storage unit stores program code that is executable by the processing unit 410 to cause the processing unit 410 to perform steps according to various exemplary embodiments of the present invention as described in the above section "exemplary methods" of the present specification. For example, the processing unit 410 may perform steps S110 to S140 as shown in fig. 1.
The storage unit 420 may include readable media in the form of volatile storage units, such as a random access memory unit (RAM)4201 and/or a cache memory unit 4202, and may further include a read only memory unit (ROM) 4203.
The storage unit 420 may also include a program/utility 4204 having a set (at least one) of program modules 4205, such program modules 4205 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 430 may be any bus representing one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 400 may also communicate with one or more external devices 470 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 400, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 400 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 450. Also, the electronic device 400 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 460. As shown, the network adapter 460 communicates with the other modules of the electronic device 400 over the bus 430. It should be appreciated that although not shown in the figures, other hardware and/or software modules may be used in conjunction with electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a web server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of the present specification. In some possible embodiments, aspects of the invention may also be implemented in the form of a program product comprising program code means for causing a terminal device to carry out the steps according to various exemplary embodiments of the invention described in the above-mentioned "exemplary methods" section of the present description, when said program product is run on the terminal device.
Referring to fig. 5, a program product 500 for implementing the above method according to an embodiment of the present invention is described, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited in this regard and, in the present document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or web server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
Furthermore, the above-described figures are merely schematic illustrations of processes involved in methods according to exemplary embodiments of the invention, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is to be limited only by the terms of the appended claims.