Web page processing method, device, equipment and storage medium
By querying and displaying the response information of historical access requests in the cache, the problem of inaccessibility of the activity page after it goes offline is solved, web page playback is achieved, and review and analysis are facilitated.
Patent Information
- Application Number
- CN202410592436.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-13
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-05-13
AI Technical Summary
After the event ended, product developers were unable to access the offline event page normally, resulting in the inability to conduct review analysis and sorting.
By querying the response information of historical access requests in the cache, the key elements of the target web page are generated and displayed, and the results of the interactive operation are displayed during the interactive operation to achieve web page playback.
It enables review, analysis and sorting even after the webpage is offline, improving the user experience.
Smart Images

Figure CN118520183B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer front-end development, and in particular to a web page processing method, apparatus, device, and storage medium. Background Art
[0002] In the field of computer front-end development, H5 (HyperText Markup Language 5, the fifth generation of Hypertext Markup Language) technology is often used to present web pages.
[0003] Take event pages, for example. As we all know, events are often tied to major holidays and, therefore, are time-sensitive. For example, New Year's events are only available around the New Year. However, after an event ends, a common problem arises: product developers want to revisit the event page to review and analyze the event. However, since the event has ended, the server no longer provides data services related to the event. This means the event page is offline and inaccessible, preventing product developers from carrying out their work.
[0004] Based on the above description, it can be seen that there is an urgent need for a web page processing method to facilitate users to review, analyze and sort out completed events, such as to facilitate product development personnel to review, analyze and sort out the event after the event ends. Summary of the Invention
[0005] The present disclosure provides a webpage processing method, apparatus, device, and storage medium. The technical solution of the present disclosure is as follows:
[0006] According to a first aspect of an embodiment of the present disclosure, a webpage processing method is provided, which is applied to a user device, and the method includes:
[0007] generating a first access request to a target webpage, where the target webpage is a page that has been offline;
[0008] If there is a historical access request matching the first access request in the cache, obtaining response information of the historical access request from the cache;
[0009] Displaying the response information, wherein the response information includes key elements of the target webpage, and the key elements are used to interact with the target webpage;
[0010] In response to the interactive operation on the key elements in the response information, the interactive operation result is displayed.
[0011] In some embodiments, when a historical access request matching the first access request exists in the cache, obtaining response information of the historical access request from the cache includes:
[0012] Obtaining the webpage source code of the target webpage from the cache, and executing the webpage source code;
[0013] The webpage source code is generated by the webpage processing device in the process of simulating a user accessing the target webpage based on an intercepted request-response combination and a webpage playback code; the webpage playback code is used for webpage playback when executed; the request-response combination includes a second access request for the target webpage and response information for the second access request;
[0014] The first access request is intercepted during code execution. If the first access request matches the second access request, it is determined that there is a historical access request matching the first access request in the cache, and the response information of the second access request is used as the response information of the first access request.
[0015] In some embodiments, the method further comprises:
[0016] In a case where the first access request does not match the second access request, it is determined that no historical access request matching the first access request exists in the cache, and response information of the first access request is obtained from the server.
[0017] In some embodiments, the cache is a distributed cache node; obtaining the webpage source code of the target webpage from the cache includes:
[0018] Obtain the webpage source code from the nearest cache node.
[0019] In some embodiments, the webpage source code is obtained by injecting the request-response combination and the webpage playback code into the original webpage source code of the target webpage; and executing the webpage source code includes:
[0020] The original webpage source code of the target webpage and the webpage playback code are executed.
[0021] According to a second aspect of an embodiment of the present disclosure, a webpage processing method is provided, which is applied to a webpage processing device. The method includes:
[0022] In the process of simulating a user accessing a target webpage, intercepting a second access request initiated to the server and response information of the second access request;
[0023] updating the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code; wherein the request-response combination includes the second access request and the response information; and the webpage playback code is used for webpage playback when executed;
[0024] Storing the updated webpage source code in a cache;
[0025] When the user accesses the target web page, the user device is used to obtain the updated web page source code from the cache and execute the updated web page source code; during the code execution process, the user device is used to intercept the first access request to the target web page and obtain response information of the first access request.
[0026] In some embodiments, intercepting the second access request initiated to the server and the response information of the second access request includes:
[0027] Listening for request events on the target web page;
[0028] In the case of monitoring the second access request, monitoring a request completion event on the target webpage;
[0029] When monitoring that the second access request is completed, obtaining the URL of the second access request and the response information of the second access request, and storing the response information of the second access request in the first array;
[0030] In response to the URL beginning with a preset domain name and the URL not being redirected, the second access request is stored in the first array.
[0031] In some embodiments, when the second access request is monitored, the method further includes:
[0032] In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing the function into a second array;
[0033] In response to the target webpage currently being in a non-pause state, calling the first method to continue the second access request;
[0034] The pause state means that the page is paused every time an access request is intercepted; the first method is used to continue the request when executed.
[0035] In some embodiments, upon monitoring that the second access request is completed, the method further includes:
[0036] In response to the URL not beginning with the preset domain name, the second access request is filtered out and request events continue to be monitored on the target web page.
[0037] In some embodiments, intercepting the second access request initiated to the server and the response information of the second access request includes:
[0038] Simulate a user accessing the target web page through a headless browser, enable the interception function and initialize it;
[0039] After completing the initialization, the second access request initiated by the headless browser to the server and the response information returned by the server are intercepted.
[0040] In some embodiments, updating the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code includes:
[0041] The second access request, the response information of the second access request and the web page playback code are injected into the original web page source code of the target web page to obtain the updated web page source code.
[0042] According to a third aspect of an embodiment of the present disclosure, there is provided a webpage processing apparatus, comprising:
[0043] an interception module configured to intercept a second access request initiated to the server and response information of the second access request during a process of simulating a user accessing a target webpage;
[0044] an update module configured to update the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code; wherein the request-response combination includes the second access request and the response information; and the webpage playback code is used for webpage playback when executed;
[0045] a processing module configured to store the updated webpage source code in a cache;
[0046] When the user accesses the target web page, the user device is used to obtain the updated web page source code from the cache and execute the updated web page source code; during the code execution process, the user device is used to intercept the first access request to the target web page and obtain response information of the first access request.
[0047] In some embodiments, the interception module is configured to:
[0048] Listening for request events on the target web page;
[0049] In the case of monitoring the second access request, monitoring a request completion event on the target webpage;
[0050] When monitoring that the second access request is completed, obtaining the URL of the second access request and the response information of the second access request, and storing the response information of the second access request in the first array;
[0051] In response to the URL beginning with a preset domain name and the URL not being redirected, the second access request is stored in the first array.
[0052] In some embodiments, when the second access request is monitored, the interception module is configured to:
[0053] In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing the function into a second array;
[0054] In response to the target webpage currently being in a non-pause state, calling the first method to continue the second access request;
[0055] The pause state means that the page is paused every time an access request is intercepted; the first method is used to continue the request when executed.
[0056] In some embodiments, when the second access request is monitored to be completed, the interception module is configured to: in response to the URL not starting with the preset domain name, filter out the second access request and continue to monitor request events on the target web page.
[0057] In some embodiments, the interception module is configured to:
[0058] Simulate a user accessing the target web page through a headless browser, enable the interception function and initialize it;
[0059] After completing the initialization, the second access request initiated by the headless browser to the server and the response information returned by the server are intercepted.
[0060] In some embodiments, the update module is configured to:
[0061] The second access request, the response information of the second access request and the web page playback code are injected into the original web page source code of the target web page to obtain the updated web page source code.
[0062] According to a fourth aspect of an embodiment of the present disclosure, there is provided a webpage processing apparatus, comprising:
[0063] a generating module configured to generate a first access request to a target webpage, wherein the target webpage is a page that has been offline;
[0064] an acquisition module configured to, if a historical access request matching the first access request exists in the cache, acquire response information of the historical access request from the cache;
[0065] A display module configured to display the response information, wherein the response information includes key elements of the target webpage, and the key elements are used to interact with the target webpage;
[0066] The display module is further configured to display an interactive operation result in response to an interactive operation on a key element in the response information.
[0067] In some embodiments, the acquisition module is configured to:
[0068] Obtaining the webpage source code of the target webpage from the cache, and executing the webpage source code;
[0069] The webpage source code is generated by the webpage processing device in the process of simulating a user accessing the target webpage based on an intercepted request-response combination and a webpage playback code; the webpage playback code is used for webpage playback when executed; the request-response combination includes a second access request for the target webpage and response information for the second access request;
[0070] The first access request is intercepted during code execution. If the first access request matches the second access request, it is determined that there is a historical access request matching the first access request in the cache, and the response information of the second access request is used as the response information of the first access request.
[0071] In some embodiments, the acquisition module is further configured to:
[0072] In a case where the first access request does not match the second access request, it is determined that no historical access request matching the first access request exists in the cache, and response information of the first access request is obtained from the server.
[0073] In some embodiments, the cache is a distributed cache node; the acquisition module is further configured to:
[0074] Obtain the webpage source code from the nearest cache node.
[0075] In some embodiments, the webpage source code is obtained by injecting the request-response combination and the webpage playback code into the original webpage source code of the target webpage; the acquisition module is further configured to:
[0076] The original webpage source code of the target webpage and the webpage playback code are executed.
[0077] According to a fifth aspect of an embodiment of the present disclosure, an electronic device is provided, the electronic device including:
[0078] one or more processors;
[0079] a memory for storing program codes executable by the processor;
[0080] The processor is configured to execute the program code to implement the web page processing method.
[0081] According to a sixth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, which enables the electronic device to execute the above-mentioned web page processing method when the program code in the computer-readable storage medium is executed by a processor of the electronic device.
[0082] According to a seventh aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which implements the above-mentioned web page processing method when executed by a processor of an electronic device.
[0083] The web page processing solution provided by the disclosed embodiments involves the following: when a user accesses a web page that is offline, the user device will first query the cache to see if there is a historical access request matching the currently generated access request. If so, the response information for the historical access request is directly retrieved from the cache, and the current access request is then responded to based on the retrieved response information, simulating a server response during the web page's execution phase, thereby achieving a web page playback effect. Because web page playback is implemented, this solution greatly facilitates user review, analysis, and organization of completed events.
[0084] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0086] Figure 1 The figure is a schematic diagram showing an implementation environment of a web page processing method according to an exemplary embodiment.
[0087] Figure 2 The figure is a flowchart of a web page processing method according to an exemplary embodiment.
[0088] Figure 3 The figure is a flowchart of another web page processing method according to an exemplary embodiment.
[0089] Figure 4 The figure is a flowchart of another web page processing method according to an exemplary embodiment.
[0090] Figure 5 The figure is a block diagram of a web page processing device according to an exemplary embodiment.
[0091] Figure 6 It is a block diagram of another web page processing device according to an exemplary embodiment.
[0092] Figure 7 It is a block diagram of a terminal according to an exemplary embodiment.
[0093] Figure 8 The figure is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0094] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0095] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0096] The information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0097] Figure 1 The figure is a schematic diagram showing an implementation environment of a web page processing method according to an exemplary embodiment.
[0098] See also Figure 1 The implementation environment includes: a user device 101, a server 102 located at the backend side, a distributed cache node 103 and a web page processing device 104.
[0099] User device 101 is an electronic device used by a user. In the disclosed embodiment, user device 101 has a browser installed, allowing the user to access web pages through the browser installed on user device 101. Server 102 serves as the website's origin server, providing web resources. Cache node 103 is also known as a cache server or edge server. Exemplarily, cache node 103 is a CDN (Content Delivery Network) node.
[0100] Exemplarily, the web page processing device 104 is located on the server 102. Alternatively, the web page processing device 104 may also be located on a server other than the server 102 and the cache node 103 on the backend side, which is not limited in this disclosure. Figure 1 The web page processing device 104 is located on the server 102 as an example for description.
[0101] Furthermore, when users access a website, a distributed deployment eliminates the need to access the website's origin server. Instead, global load balancing technology directs user requests directly to the geographically closest cache node. This ensures that the cache node is functioning properly, and that the access path and data transmission are secure. This cache node directly responds to the user's request. Accessing the cache node not only avoids network congestion but also makes data transmission faster and more stable.
[0102] In some embodiments, the user device 101 is a type of device such as a smart phone, a desktop computer, or a laptop computer. Figure 1 The user device 101 is described as a smartphone. It will be appreciated by those skilled in the art that the number of user devices may be greater or lesser. For example, there may be only a few user devices, or dozens, hundreds, or even more. The present disclosure does not limit the number or type of user devices.
[0103] In addition, the server 102 is connected to the user equipment 101 via a wireless network or a wired network. In addition, the server involved in the embodiment of the present disclosure may also include other functional servers to provide more comprehensive and diversified services.
[0104] The web page processing solution provided by the embodiments of the present disclosure is described in detail below through the following embodiments.
[0105] Figure 2 is a flow chart showing a web page processing method according to an exemplary embodiment. Figure 2 As shown, the web page processing method is applied to electronic devices, such as Figure 1 The web page processing method includes the following steps:
[0106] In 201 , the electronic device generates a first access request to a target webpage, where the target webpage is an offline page.
[0107] Among them, the target webpage in the embodiment of the present disclosure generally refers to any webpage, such as a portal website page, an activity page, etc., and the present disclosure does not limit this. In particular, the target webpage is a page that has been offline, that is, the target webpage can no longer be accessed normally. Taking the target webpage as an activity page as an example, it is well known that activities are usually related to major holidays, so activities are generally time-sensitive. For example, activities related to the New Year are only online around the New Year. However, after the event ends, the server no longer provides data services related to this event, that is, the target webpage cannot be accessed normally.
[0108] In addition, in order to distinguish different access requests, the access request generated in this step is also referred to as the first access request.
[0109] In 202 , when there is a historical access request matching the first access request in the cache, the electronic device obtains response information of the historical access request from the cache.
[0110] In some embodiments, the cache is a distributed cache node, which is also called a cache server or edge server. For example, the cache node is a CDN node.
[0111] For this step, if the first access request is consistent with the historical access request stored in the cache, the response information of the historical access is selected as the response matching the first access request.
[0112] In 203 , the electronic device displays the response information, where the response information includes key elements of the target webpage, wherein the key elements are used to interact with the target webpage.
[0113] In some embodiments, the electronic device displays the response message in the form of a web page, which is not limited in this disclosure.
[0114] In other embodiments, in addition to the key elements, the response information also includes non-key elements of the target webpage, wherein the non-key elements do not support interaction with the target webpage, which is not limited in the present disclosure.
[0115] In 204 , in response to the interactive operation on the key elements in the response information, the electronic device displays the interactive operation result.
[0116] In other embodiments, the above-mentioned interactive operations involved in interacting with the target web page include, but are not limited to, gesture interaction operations, text input operations, or picture upload operations, etc., which are not limited in this disclosure.
[0117] The web page processing solution provided by the disclosed embodiments involves the following: when a user accesses a web page that is offline, the user device will first query the cache to see if there is a historical access request matching the currently generated access request. If so, the response information for the historical access request is directly retrieved from the cache, and the current access request is then responded to based on the retrieved response information, simulating a server response during the web page's execution phase, thereby achieving a web page playback effect. Because web page playback is implemented, this solution greatly facilitates user review, analysis, and organization of completed events.
[0118] Figure 3 is a flow chart showing another web page processing method according to an exemplary embodiment. Figure 3 As shown, the web page processing method is applied to electronic devices, such as Figure 1 The web page processing device shown. The web page processing method includes the following steps:
[0119] In 301 , in the process of simulating a user accessing a target webpage, the electronic device intercepts a second access request initiated to a server and response information of the second access request.
[0120] In some embodiments, a headless browser is used to simulate a user accessing a target webpage on the backend. A headless browser is a browser program that lacks a graphical user interface (GUI) but performs functions similar to those of a regular browser. A headless browser can load and parse webpages, execute JavaScript code, handle webpage events, and provide access to and manipulation of the Document Object Model (DOM).
[0121] JavaScript is a scripting language that can implement complex functions on web pages. Using JS allows web pages to no longer just display static content, but to update content in real time. In other words, JS can be used to create dynamically updated content, such as animations.
[0122] In other embodiments, the target webpage is an H5 page. H5 refers to the fifth generation of HTML and also refers to all digital products created using the H5 language. Most webpages are written in HTML. "Hypertext" means that a page can contain images, links, and even non-text elements such as music and programs. "Markup" means that hypertext must be marked with opening and closing tags containing attributes. A browser program can display the webpage's content by decoding HTML.
[0123] When using headless browsing to simulate a user accessing a target webpage, the disclosed embodiment will enable the interception function and inject the user's identity credentials (cookies). After the interception function is enabled, the network requests initiated by the headless browser to the server and the responses returned by the server will be intercepted. For details on how to intercept network requests and responses, please refer to the following description.
[0124] It should be noted that cookies are small text files generated by the server and are used to identify users.
[0125] In 302, the electronic device updates the web page source code of the target web page based on the intercepted request-response combination and the web page playback code; wherein the request-response combination includes the second access request and corresponding response information; the web page playback code is used for web page playback when executed.
[0126] After intercepting the second access request and the corresponding response information, the embodiment of the present disclosure will record them. In addition, the embodiment of the present disclosure will also record the HTML of the target web page, that is, the web page source code.
[0127] In some embodiments, based on the webpage source code of the target webpage, the second access request, the corresponding response information, and the webpage playback code, the webpage source code of the target webpage is updated, including but not limited to the following methods:
[0128] The second access request, the corresponding response information and the web page playback code are injected into the web page source code of the target web page to obtain the updated web page source code of the target web page.
[0129] Exemplarily, the web page playback code is JS code. Specifically, for the target web page, the source code of the web page is modified by injecting the recorded second access request and corresponding response information, as well as the code for web page playback, into the web page source code. This results in a modified version of the web page source code. Finally, this new HTML is uploaded to a cache, such as a distributed cache node. In this way, when a user actually accesses the target web page, the access request initiated by the user can be responded to based on the modified version stored in the cache, providing basic support for web page recording and playback.
[0130] In 303, the electronic device stores the updated web page source code in the cache; when the user accesses the target web page, the user device is used to obtain the updated web page source code from the cache and execute the updated web page source code; during the code execution process, the user device is used to intercept the first access request to the target web page and obtain response information of the first access request.
[0131] Exemplarily, the cache node mentioned above refers to a group of servers distributed in various regions, such as CDN.
[0132] Correspondingly, distributed deployment means that in addition to the source server, cache nodes will be deployed in multiple regions based on geographical location, so that user-initiated requests can be sent directly to the cache node closest to them, thereby avoiding direct access to the source server. This can not only improve system security to a certain extent, but also increase the response speed to requests.
[0133] Here, "user access to the target webpage" refers to a real user accessing the target webpage through a browser program in a real environment. The cache node here refers to the cache node geographically closest to the user. In other words, the user device is used to obtain the updated webpage source code from the cache node closest to the user. "Executing the updated webpage source code" refers to executing the webpage source code and webpage playback code in the updated webpage source code, excluding the request and response.
[0134] The web page processing solution provided by the embodiment of the present disclosure realizes web page recording and playback. For the recording process, the solution will simulate the user accessing the web page, intercept the access request initiated to the server and the response information returned by the server, and record the intercepted access request and response information; in addition, the solution will also record the web page source code of the target web page, and then generate the updated web page source code of the web page based on the web page source code of the web page, the intercepted access request and response information, and the web page playback code, and store it in the cache. In this way, when the user actually accesses the web page, the user device will give priority to obtaining the updated web page source code from the cache and execute the updated web page source code. During the code execution process, the user device will intercept the currently generated access request, and then respond to the access request intercepted at this time, so as to simulate the server return response during the web page running stage, thereby achieving the web page playback effect.
[0135] In summary, since web page recording and playback are realized, this solution greatly facilitates users to review, analyze and sort out completed events.
[0136] above Figure 2-3 The following is only a basic process of the present disclosure. The solution provided by the present disclosure is further described based on a specific implementation method. Figure 4 is a flow chart showing another web page processing method according to an exemplary embodiment. Figure 3 As shown, taking the interaction between the user device, the server, the cache node and the web page processing device as an example, the web page processing method includes the following steps:
[0137] In 401 , in the process of using a headless browser to simulate a user accessing a target web page, the web page processing device intercepts a second access request initiated to a server and response information of the second access request returned by the server.
[0138] In the disclosed embodiment, the principle of intercepting the access request (also called network request) initiated on the target web page and the response information returned by the server is as follows:
[0139] 1. Enable the interception function and initialize it.
[0140] In some embodiments, the initialization process includes: first, creating an empty array results; wherein the empty array results is used to collect interception results. Next, defining a variable paused and an array pausedRequests, wherein the variable paused is used to identify whether the page is currently paused, and the array pausedRequests is used to store network requests when the page is paused. Then, a function nextRequest() is also defined, wherein, when executed, the function nextRequest() is used to continue the next request or release the paused state.
[0141] The pause state means that the page is paused every time a network request is intercepted. In addition, the empty array results is also referred to as the first array in this article, and the array pausedRequests is also referred to as the second array in this article.
[0142] 2. Listen for request events on the target web page.
[0143] This step is to listen for request events on the page. When a network request is initiated, a callback function is triggered to handle the network request.
[0144] 3. In response to the target webpage currently being in a paused state, encapsulate the first method of the second access request into a function and store it in a second array.
[0145] The first method refers to the request.continue() method, which is used to continue the request when executed.
[0146] This step is to encapsulate the request.continue() method of the request into a function and store it in the pausedRequests array if the page is currently in a paused state.
[0147] 4. In response to the target webpage currently being in a non-pause state, calling the first method to continue the second access request.
[0148] Once interception is enabled, each network request will be stopped unless it continues, responds, or is aborted. This step is to call the request.continue() method to continue the request.
[0149] 5. Listen for the requestfinished event on the target web page.
[0150] 6. When monitoring that the second access request is completed, obtain the URL and the first response of the second access request, and store the first response in the first array.
[0151] The above-mentioned website address is a URL (Uniform Resource Locator). Exemplarily, storing the first response in the first array means storing the response header and response body of the first response in the array results.
[0152] 7. In response to the URL of the second access request starting with a preset domain name and the URL is not redirected, the second access request is stored in the first array.
[0153] For this step, if the URL of the second access request begins with a preset domain name and is not redirected, the second access request is stored in the array results. Exemplarily, the embodiment of the present disclosure stores the URL, request header, and request body of the second access request in the array results.
[0154] 8. In response to the URL of the second access request not beginning with the preset domain name, the second access request is filtered out and request events are continued to be monitored on the target web page.
[0155] If the URL of the second access request does not start with the preset domain name, the function nextRequest() is called to continue the next request and this request is directly ignored.
[0156] 9. Listen for the request failed event on the target web page.
[0157] 10. Handle the request failure and call the function nextRequest() to continue the next request.
[0158] In summary, after the interception function is enabled, the embodiment of the present disclosure can accurately intercept the access request initiated on the page and the response information returned by the server by setting arrays and variables, defining functions, enabling event monitoring, etc., which provides basic protection and support for the recording and playback of web pages. In addition, the embodiment of the present disclosure simulates the operation of users accessing web pages through a headless browser, which also provides basic protection and support for the recording and playback of web pages. In addition, the embodiment of the present disclosure implements the classification processing of access requests by monitoring request events, request completion events, and judging the domain name type, etc., which can intercept useful access requests and release useless access requests, with good processing effect. In addition, the embodiment of the present disclosure will also process request failure events, and realize effective processing when the request fails.
[0159] In 402, the web page processing device updates the web page source code of the target web page based on the intercepted request-response combination and the web page playback code; wherein the request-response combination includes the second access request and corresponding response information; the web page playback code is used for web page playback when executed.
[0160] Please refer to the above step 302 for this step, which will not be repeated here.
[0161] In 403 , the web page processing device stores the updated web page source code in a distributed cache node.
[0162] Please refer to the above step 303 for this step, which will not be repeated here.
[0163] The above steps 401-403 are the web page recording process, and the following steps 404-406 will introduce the web page playback process.
[0164] In 404 , when a user accesses a target webpage, the user device generates a first access request to the target webpage.
[0165] Please refer to the above step 201 for this step, which will not be repeated here.
[0166] In 405 , when there is a historical access request matching the first access request in the cache node, the user equipment obtains response information of the historical access request from the cache node.
[0167] In some embodiments, to increase data acquisition speed, the user device acquires the target webpage source code from the cache node closest to the user and executes the acquired webpage source code. During the code execution process, the user device intercepts the first access request.
[0168] After obtaining the webpage source code, the browser installed on the user's device executes the obtained webpage source code to display the webpage content. In the disclosed embodiment, executing the webpage source code refers to executing the webpage source code and webpage playback code in the webpage source code, excluding the request and response. During the code execution process, the first access request is intercepted and then compared with the historical access requests stored in the cache node.
[0169] For example, this step intercepts access requests initiated through XMLHttpRequest (a set of API functions) and Fetch. Fetch is a network-provided API for asynchronous resource retrieval. XMLHttpRequest is a JavaScript class that contains methods for asynchronously transmitting HTTP (Hypertext Transfer Protocol) requests from a browser to a server. These methods allow browser-based applications to make fine-grained server calls and store the results in the XMLHttpRequest's responseText property.
[0170] In this step, if the first access request successfully matches a historical access request stored in the cache node, the response information for the historical access request can be directly returned without making an actual request. This not only improves page loading speed and performance, but also eliminates the need to retrieve data from the server again, saving server costs and ensuring effective human-computer interaction. In other words, this processing method enables local caching of requests and web page playback, resulting in faster response times and a significantly improved user experience.
[0171] In addition, when the first access request does not match the second access request, it is determined that there is no historical access request matching the first access request in the cache node, then the request will be made according to the normal process, that is, the corresponding response information will be obtained from the server. This processing method realizes that the response is obtained from the server only when necessary, saving server costs.
[0172] For example, when determining whether the first access request matches the historical access request, it may be determined whether the URLs of the two are consistent; if the URLs of the two are consistent, it is determined that the first access request matches the historical access request.
[0173] In 406 , the user device displays the response information, which includes key elements of the target webpage, wherein the key elements are used to interact with the target webpage; in response to the interactive operation on the key elements in the response information, the user device displays the interactive operation result.
[0174] The web page processing solution provided by the embodiment of the present disclosure realizes web page recording and self-playback of web pages through a headless browser.
[0175] For the recording process, the solution uses a headless browser to simulate users accessing web pages, intercepting access requests initiated to the server and the responses returned by the server, and recording the intercepted access requests and responses; in addition, the solution also records the web page source code of the target web page, and then generates the updated web page source code of the web page based on the web page source code, intercepted access requests and responses, and web page playback code, and stores it in the distributed cache nodes.
[0176] Regarding the playback process, when the user actually visits the web page, the user device will obtain the web page source code from the cache node (here specifically refers to the updated web page source code, not the original web page source code) and execute the web page source code. During the code execution process, the user device will intercept the generated access request and then respond to the access request intercepted at this time, thereby simulating the server return response during the web page running phase, thereby achieving the web page playback effect.
[0177] In summary, the disclosed embodiments can achieve web page recording and playback at a low cost without affecting normal online pages. Since web page recording and playback are enabled, this solution greatly facilitates users to review, analyze, and sort out completed events. Furthermore, since access requests and responses do not need to be stored on the server for a long time, but are instead stored on distributed cache nodes, this not only saves server costs but also increases the speed of responding to access requests.
[0178] Figure 5 FIG. 1 is a block diagram of a web page processing device according to an exemplary embodiment. Figure 5 , the device comprises:
[0179] The interception module 501 is configured to intercept the second access request initiated to the server and the response information of the second access request during the process of simulating the user accessing the target webpage;
[0180] An update module 502 is configured to update the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code, wherein the request-response combination includes the second access request and the response information; and the webpage playback code is used for webpage playback when executed;
[0181] The processing module 503 is configured to store the updated webpage source code in a cache;
[0182] When the user accesses the target web page, the user device is used to obtain the updated web page source code from the cache and execute the updated web page source code; during the code execution process, the user device is used to intercept the first access request to the target web page and obtain response information of the first access request.
[0183] The web page processing solution provided by the embodiment of the present disclosure realizes web page recording and playback. For the recording process, the solution will simulate the user accessing the web page, intercept the access request initiated to the server and the response information returned by the server, and record the intercepted access request and response information; in addition, the solution will also record the web page source code of the target web page, and then generate the updated web page source code of the web page based on the web page source code of the web page, the intercepted access request and response information, and the web page playback code, and store it in the cache. In this way, when the user actually accesses the web page, the user device will give priority to obtaining the updated web page source code from the cache and execute the updated web page source code. During the code execution process, the user device will intercept the currently generated access request, and then respond to the access request intercepted at this time, so as to simulate the server return response during the web page running stage, thereby achieving the web page playback effect.
[0184] In summary, since web page recording and playback are realized, this solution greatly facilitates users to review, analyze and sort out completed events.
[0185] In some embodiments, the interception module 501 is configured to:
[0186] Listening for request events on the target web page;
[0187] In the case of monitoring the second access request, monitoring a request completion event on the target webpage;
[0188] When monitoring that the second access request is completed, obtaining the URL of the second access request and the response information of the second access request, and storing the response information of the second access request in the first array;
[0189] In response to the URL beginning with a preset domain name and the URL not being redirected, the second access request is stored in the first array.
[0190] In some embodiments, when the second access request is monitored, the interception module 501 is configured to:
[0191] In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing the function into a second array;
[0192] In response to the target webpage currently being in a non-pause state, calling the first method to continue the second access request;
[0193] The pause state means that the page is paused every time an access request is intercepted; the first method is used to continue the request when executed.
[0194] In some embodiments, when the second access request is monitored to be completed, the interception module 501 is configured to: in response to the URL not starting with the preset domain name, filter out the second access request and continue to monitor request events on the target web page.
[0195] In some embodiments, the interception module 501 is configured to:
[0196] Simulate a user accessing the target web page through a headless browser, enable the interception function and initialize it;
[0197] After completing the initialization, the second access request initiated by the headless browser to the server and the response information returned by the server are intercepted.
[0198] In some embodiments, the update module 502 is configured to:
[0199] The second access request, the response information of the second access request and the web page playback code are injected into the original web page source code of the target web page to obtain the updated web page source code.
[0200] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.
[0201] Figure 6 FIG. 1 is a block diagram of a web page processing device according to an exemplary embodiment. Figure 6 , the device comprises:
[0202] A generating module 601 is configured to generate a first access request to a target webpage, where the target webpage is a page that has been offline.
[0203] an acquisition module 602 configured to, if a historical access request matching the first access request exists in the cache, acquire response information of the historical access request from the cache;
[0204] A display module 603 is configured to display the response information, wherein the response information includes key elements of the target webpage, and the key elements are used to interact with the target webpage;
[0205] The display module 603 is further configured to display the interactive operation result in response to the interactive operation on the key elements in the response information.
[0206] The web page processing solution provided by the disclosed embodiments involves the following: when a user accesses a web page that is offline, the user device will first query the cache to see if there is a historical access request matching the currently generated access request. If so, the response information for the historical access request is directly retrieved from the cache, and the current access request is then responded to based on the retrieved response information, simulating a server response during the web page's execution phase, thereby achieving a web page playback effect. Because web page playback is implemented, this solution greatly facilitates user review, analysis, and organization of completed events.
[0207] In some embodiments, the acquisition module 602 is configured to:
[0208] Obtaining the webpage source code of the target webpage from the cache, and executing the webpage source code;
[0209] The webpage source code is generated by the webpage processing device in the process of simulating a user accessing the target webpage based on an intercepted request-response combination and a webpage playback code; the webpage playback code is used for webpage playback when executed; the request-response combination includes a second access request for the target webpage and response information for the second access request;
[0210] The first access request is intercepted during code execution. If the first access request matches the second access request, it is determined that there is a historical access request matching the first access request in the cache, and the response information of the second access request is used as the response information of the first access request.
[0211] In some embodiments, the acquisition module 602 is further configured to:
[0212] In a case where the first access request does not match the second access request, it is determined that no historical access request matching the first access request exists in the cache, and response information of the first access request is obtained from the server.
[0213] In some embodiments, the cache is a distributed cache node;
[0214] The acquisition module 602 is further configured to acquire the webpage source code from the nearest cache node.
[0215] In some embodiments, the webpage source code is obtained by injecting the request-response combination and the webpage playback code into the original webpage source code of the target webpage;
[0216] The acquisition module 602 is further configured to execute the original webpage source code of the target webpage and the webpage playback code.
[0217] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.
[0218] It should be noted that the web page processing device provided in the above embodiment is merely an example of the division of the aforementioned functional units when performing web page processing. In actual applications, the aforementioned functions can be assigned to different functional units as needed, that is, the internal structure of the electronic device can be divided into different functional units to perform all or part of the functions described above. Furthermore, the web page processing device provided in the above embodiment and the web page processing method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0219] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0220] In some embodiments, an electronic device is further provided, the electronic device comprising:
[0221] one or more processors;
[0222] a memory for storing program code executable by the processor;
[0223] The processor is configured to execute the program code to implement the web page processing method.
[0224] In response to the electronic device being provided as a terminal, Figure 7 is a block diagram of a terminal 700 according to an exemplary embodiment.
[0225] Typically, the terminal 700 includes a processor 701 and a memory 702 .
[0226] The processor 701 includes one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 701 is implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Alternatively, the processor 701 includes a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 701 is integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 701 also includes an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0227] The memory 702 includes one or more computer-readable storage media, which are non-transitory. The memory 702 also includes high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 702 is used to store at least one program code, which is executed by the processor 701 to implement the webpage processing method provided in the method embodiment of the present disclosure.
[0228] In some embodiments, terminal 700 further includes a peripheral device interface 703 and at least one peripheral device. Processor 701, memory 702, and peripheral device interface 703 are connected via a bus or signal lines. Each peripheral device is connected to peripheral device interface 703 via a bus, signal lines, or circuit boards. The peripheral device includes at least one of a radio frequency circuit 704, a display screen 705, a camera assembly 706, an audio circuit 707, and a power supply 708.
[0229] The peripheral device interface 703 is used to connect at least one I / O (Input / Output)-related peripheral device to the processor 701 and the memory 702. In some embodiments, the processor 701, the memory 702, and the peripheral device interface 703 are integrated on the same chip or circuit board; in other embodiments, any one or two of the processor 701, the memory 702, and the peripheral device interface 703 are implemented on separate chips or circuit boards, which is not limited in this disclosure.
[0230] The RF circuit 704 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 704 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 704 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. In some embodiments, the RF circuit 704 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 704 communicates with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 704 also includes circuitry related to Near Field Communication (NFC), which is not limited in this disclosure.
[0231] Display screen 705 is used to display a user interface (UI). This UI includes graphics, text, icons, videos, and any combination thereof. If display screen 705 is a touchscreen display, it is also capable of collecting touch signals on or above the surface of display screen 705. These touch signals are input as control signals to processor 701 for processing. In this case, display screen 705 is also used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there is a single display screen 705, located on the front panel of terminal 700; in other embodiments, there are at least two display screens 705, located on different surfaces of terminal 700 or in a foldable design; in still other embodiments, display screen 705 is a flexible display, located on a curved or foldable surface of terminal 700. Alternatively, display screen 705 can be configured as a non-rectangular, irregular shape, also known as a special-shaped screen. Display screen 705 is made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0232] The camera assembly 706 is used to capture images or videos. In some embodiments, the camera assembly 706 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In other embodiments, the camera assembly 706 also includes a flash. The flash is a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which is used for light compensation at different color temperatures.
[0233] The audio circuit 707 includes a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 701 for processing, or input them into the radio frequency circuit 704 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there are multiple microphones, which are respectively arranged at different parts of the terminal 700. Alternatively, the microphone is an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signals from the processor 701 or the radio frequency circuit 704 into sound waves. The speaker is a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signals into sound waves audible to humans, but also convert the electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 707 also includes a headphone jack.
[0234] Power supply 708 is used to power various components in terminal 700. Power supply 708 can be AC power, DC power, a disposable battery, or a rechargeable battery. If power supply 708 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is charged via a wired line, while a wireless rechargeable battery is charged via a wireless coil. The rechargeable battery is also configured to support fast charging technology.
[0235] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the terminal 700, and the terminal 700 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0236] In some embodiments, when the electronic device is provided as a server, Figure 8 1 is a block diagram of a server 800 according to an embodiment of the present disclosure. The server 800 may have relatively large differences due to different configurations or performances, and includes one or more processors (Central Processing Units, CPU) 801 and one or more memories 802, wherein the memory 802 stores at least one program code, and the at least one program code is loaded and executed by the processor 801 to implement the web page processing methods provided by the above-mentioned various method embodiments. Of course, the server also has components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 800 also includes other components for implementing device functions, which are not described here.
[0237] In some embodiments, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, wherein the instructions are executed by a processor of an electronic device to implement the webpage processing method. In other embodiments, the computer-readable storage medium is a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
[0238] In some embodiments, a computer program product is also provided, including a computer program, which is executed by a processor of an electronic device to implement the above-mentioned web page processing method.
[0239] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0240] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A web page processing method, characterized in that: Applied to user equipment, the method includes: generating a first access request to a target webpage, where the target webpage is a page that has been offline; If there is a historical access request matching the first access request in the cache, obtaining response information of the historical access request from the cache; Displaying the response information, wherein the response information includes key elements of the target webpage, and the key elements are used to interact with the target webpage; In response to an interactive operation on a key element in the response information, displaying an interactive operation result; The historical access requests and response information of the historical access requests in the cache are the access requests intercepted by the headless browser when simulating a user accessing the target webpage and the response information returned by the server. The headless browser loads and parses the webpage, executes JavaScript code, processes webpage events, and provides access to and operation capabilities of the document object model; intercepting the access requests initiated on the target webpage and the response information returned by the server includes: Create an empty array for collecting interception results, define variables, arrays, and functions. The variable is used to identify whether the page is currently in a paused state. The array is used to store network requests when the page is paused. When executed, the function is used to continue the next request or release the paused state. The paused state means that the page is paused every time an access request is intercepted. Listening for request events on the target webpage, and triggering a callback function when a second access request is initiated to process the second access request; In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing it in the array, so that the first method is used to continue the request when executed; and in response to the target webpage currently being in a non-paused state, calling the first method to continue the second access request; Listening for a request completion event on the target webpage; upon listening for the completion of the second access request, obtaining a URL and a first response to the second access request, and storing the first response in the array, wherein the URL is a uniform resource locator; In response to the URL of the second access request starting with a preset domain name and the URL is not redirected, storing the second access request in the array; in response to the URL of the second access request not starting with the preset domain name, filtering out the second access request and continuing to listen for request events on the target web page; Listening for request failure events on the target web page; processing the request failure situation, and calling the function to continue with the next request.
2. The web page processing method according to claim 1, characterized in that: When a historical access request matching the first access request exists in the cache, obtaining response information of the historical access request from the cache includes: Obtaining the webpage source code of the target webpage from the cache, and executing the webpage source code; The webpage source code is generated by the webpage processing device in the process of simulating a user accessing the target webpage based on an intercepted request-response combination and a webpage playback code; the webpage playback code is used for webpage playback when executed; the request-response combination includes a second access request for the target webpage and response information for the second access request; The first access request is intercepted during code execution. If the first access request matches the second access request, it is determined that there is a historical access request matching the first access request in the cache, and the response information of the second access request is used as the response information of the first access request.
3. The web page processing method according to claim 2, characterized in that: The method further comprises: In a case where the first access request does not match the second access request, it is determined that no historical access request matching the first access request exists in the cache, and response information of the first access request is obtained from the server.
4. The web page processing method according to claim 2, wherein: The cache is a distributed cache node; The acquiring the webpage source code of the target webpage from the cache includes: Obtain the webpage source code from the nearest cache node.
5. The web page processing method according to claim 2, wherein: The webpage source code is obtained by injecting the request-response combination and the webpage playback code into the original webpage source code of the target webpage; The executing the webpage source code includes: The original webpage source code of the target webpage and the webpage playback code are executed.
6. A web page processing method, characterized in that: Applied to a web page processing device, the method includes: In the process of simulating a user accessing a target web page, intercepting a second access request initiated by the headless browser to the server and a response to the second access request; the headless browser loads and parses the web page, executes JavaScript code, processes web page events, and provides access to and operation capabilities of the document object model; updating the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code; wherein the request-response combination includes the second access request and the response information; and the webpage playback code is used for webpage playback when executed; Store the updated web page source code in the cache; When a user accesses the target webpage, the user device is configured to obtain the updated webpage source code from the cache and execute the updated webpage source code; during code execution, the user device is configured to intercept a first access request to the target webpage and obtain response information to the first access request; The intercepting of the second access request initiated by the headless browser to the server and the response information of the second access request includes: Create an empty array for collecting interception results, define variables, arrays, and functions. The variable is used to identify whether the page is currently in a paused state. The array is used to store network requests when the page is paused. When executed, the function is used to continue the next request or release the paused state. The paused state means that the page is paused every time an access request is intercepted. Listening for request events on the target webpage, and triggering a callback function when a second access request is initiated to process the second access request; In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing it in the array, so that the first method is used to continue the request when executed; and in response to the target webpage currently being in a non-paused state, calling the first method to continue the second access request; Listening for a request completion event on the target webpage; upon listening for the completion of the second access request, obtaining a URL and a first response to the second access request, and storing the first response in the array, wherein the URL is a uniform resource locator; In response to the URL of the second access request starting with a preset domain name and the URL is not redirected, storing the second access request in the array; in response to the URL of the second access request not starting with the preset domain name, filtering out the second access request and continuing to listen for request events on the target web page; Listening for request failure events on the target web page; processing the request failure situation, and calling the function to continue with the next request.
7. The web page processing method according to claim 6, characterized in that: The intercepting of the second access request initiated by the headless browser to the server and the response information of the second access request includes: Simulate a user accessing the target web page through the headless browser, enable the interception function and initialize it; After completing the initialization, the second access request initiated by the headless browser to the server and the response information returned by the server are intercepted.
8. The webpage processing method according to claim 6, characterized in that: The updating of the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code comprises: The second access request, the response information of the second access request and the web page playback code are injected into the original web page source code of the target web page to obtain the updated web page source code.
9. A web page processing device, characterized in that: The device comprises: a generating module configured to generate a first access request to a target webpage, wherein the target webpage is a page that has been offline; an acquisition module configured to, if a historical access request matching the first access request exists in the cache, acquire response information of the historical access request from the cache; A display module configured to display the response information, wherein the response information includes key elements of the target webpage, and the key elements are used to interact with the target webpage; The display module is further configured to display an interactive operation result in response to an interactive operation on a key element in the response information; The historical access requests and response information of the historical access requests in the cache are the access requests intercepted by the headless browser when simulating a user accessing the target webpage and the response information returned by the server. The headless browser loads and parses the webpage, executes JavaScript code, processes webpage events, and provides access to and operation capabilities of the document object model; intercepting the access requests initiated on the target webpage and the response information returned by the server includes: Create an empty array for collecting interception results, define variables, arrays, and functions. The variable is used to identify whether the page is currently in a paused state. The array is used to store network requests when the page is paused. When executed, the function is used to continue the next request or release the paused state. The paused state means that the page is paused every time an access request is intercepted. Listening for request events on the target webpage, and triggering a callback function when a second access request is initiated to process the second access request; In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing it in the array, so that the first method is used to continue the request when executed; and in response to the target webpage currently being in a non-paused state, calling the first method to continue the second access request; Listening for a request completion event on the target webpage; upon listening for the completion of the second access request, obtaining a URL and a first response to the second access request, and storing the first response in the array, wherein the URL is a uniform resource locator; In response to the URL of the second access request starting with a preset domain name and the URL is not redirected, storing the second access request in the array; in response to the URL of the second access request not starting with the preset domain name, filtering out the second access request and continuing to listen for request events on the target web page; Listening for request failure events on the target web page; processing the request failure situation, and calling the function to continue with the next request.
10. A web page processing device, characterized in that: The device comprises: an interception module configured to intercept a second access request initiated by the headless browser to the server and a response to the second access request during a process of simulating a user accessing a target webpage; the headless browser loads and parses the webpage, executes JavaScript code, processes webpage events, and provides access to and operation capabilities of a document object model; an update module configured to update the webpage source code of the target webpage based on the intercepted request-response combination and the webpage playback code; wherein the request-response combination includes the second access request and the response information; and the webpage playback code is used for webpage playback when executed; a processing module configured to store the updated webpage source code in a cache; When a user accesses the target webpage, the user device is configured to obtain the updated webpage source code from the cache and execute the updated webpage source code; during code execution, the user device is configured to intercept a first access request to the target webpage and obtain response information to the first access request; The intercepting of the second access request initiated by the headless browser to the server and the response information of the second access request includes: Create an empty array for collecting interception results, define variables, arrays, and functions. The variable is used to identify whether the page is currently in a paused state. The array is used to store network requests when the page is paused. When executed, the function is used to continue the next request or release the paused state. The paused state means that the page is paused every time an access request is intercepted. Listening for request events on the target webpage, and triggering a callback function when a second access request is initiated to process the second access request; In response to the target webpage currently being in a paused state, encapsulating the first method of the second access request into a function and storing it in the array, so that the first method is used to continue the request when executed; and in response to the target webpage currently being in a non-paused state, calling the first method to continue the second access request; Listening for a request completion event on the target webpage; upon listening for the completion of the second access request, obtaining a URL and a first response to the second access request, and storing the first response in the array, wherein the URL is a uniform resource locator; In response to the URL of the second access request starting with a preset domain name and the URL is not redirected, storing the second access request in the array; in response to the URL of the second access request not starting with the preset domain name, filtering out the second access request and continuing to listen for request events on the target web page; Listening for request failure events on the target web page; processing the request failure situation, and calling the function to continue with the next request.
11. An electronic device, characterized in that: The electronic device comprises: one or more processors; a memory for storing program code executable by the processor; The processor is configured to execute the program code to implement the webpage processing method according to any one of claims 1 to 5; or the webpage processing method according to any one of claims 6 to 8.
12. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the webpage processing method according to any one of claims 1 to 5; Or, a web page processing method as described in any one of claims 6 to 8.
13. A computer program product, characterized in that The method comprises a computer program, which, when executed by a processor of an electronic device, implements the web page processing method according to any one of claims 1 to 5; or the web page processing method according to any one of claims 6 to 8.
Citation Information
Patent Citations
Page display method, device and equipment and computer readable storage medium
CN117290028A
Method and device for accessing web pages
US20140108512A1