CN117762668A - Network data acquisition method, device, medium and equipment - Google Patents

Network data acquisition method, device, medium and equipment Download PDF

Info

Publication number
CN117762668A
CN117762668A CN202311755846.1A CN202311755846A CN117762668A CN 117762668 A CN117762668 A CN 117762668A CN 202311755846 A CN202311755846 A CN 202311755846A CN 117762668 A CN117762668 A CN 117762668A
Authority
CN
China
Prior art keywords
network event
network
browser
user
listener
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311755846.1A
Other languages
Chinese (zh)
Inventor
路林生
张志磊
吴满
杨丽香
郭建强
崔俊
崔丹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
360 Digital Security Technology Group Co Ltd
Original Assignee
360 Digital Security Technology Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 360 Digital Security Technology Group Co Ltd filed Critical 360 Digital Security Technology Group Co Ltd
Priority to CN202311755846.1A priority Critical patent/CN117762668A/en
Publication of CN117762668A publication Critical patent/CN117762668A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a method, a device, a medium and equipment for acquiring network data, wherein the method is applied to an extension program of a browser and comprises the following steps: registering a network event listener based on a first operation instruction input by a user; capturing a target network event of the browser based on the network event listener; and acquiring the HAR archive file of the network data corresponding to the target network event. The method and the device can conveniently capture the network data of the browser and acquire the HAR archive file of the network data, and are favorable for diagnosing and analyzing the problems of the browser in the follow-up process.

Description

Network data acquisition method, device, medium and equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and a device for acquiring network data.
Background
In Web development and maintenance, monitoring and analysis of network data is critical. Browsers provide built-in developer tools including network monitoring functionality, but these tools typically record network data in complex formats (e.g., netLog), which are difficult for non-professionals to understand and analyze. It is also difficult for an average user to actively use developer tools to record and share network problems, resulting in problem diagnosis and process delays.
Disclosure of Invention
The embodiment of the application provides a network data acquisition method, a device, a medium and equipment, which can conveniently acquire network data of a browser and acquire HAR archive files of the browser, and are favorable for diagnosing and analyzing browser problems in the follow-up process. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a method for acquiring network data, which is applied to an extension program of a browser, where the method includes:
registering a network event listener based on a first operation instruction input by a user;
capturing a target network event of the browser based on the network event monitor;
and acquiring HAR archive files of the network data corresponding to the target network events.
In one possible implementation manner, after the capturing, by the network event listener, the target network event of the browser, the method further includes:
and removing the network event monitor based on a second operation instruction input by the user.
In one possible implementation manner, after the registering the network event listener based on the first operation instruction input by the user, the method further includes:
judging whether the current network event is an abnormal network event or not based on a preset rule;
And removing the network event monitor after the current network event ends the first duration under the condition that the current network event is an abnormal network event.
In one possible implementation manner, in the case where the current network event is an abnormal network event, removing the network event listener after the current network event ends for a first duration includes:
judging whether the network event monitor captures a network event in a second duration when the current network event is ended under the condition that the current network event is an abnormal network event;
if the network event monitor captures a network event in the second time period when the current network event ends, removing the network event monitor after the first time period when the current network event ends;
wherein the second duration is less than the first duration.
In one possible implementation manner, after the determining whether the network event listener captures the network event in the second duration of the end of the current network event, the method further includes:
and if the network event monitor does not capture the network event in the second time period when the current network event is ended, removing the network event monitor after the second time period when the current network event is ended.
In one possible implementation manner, after the registering the network event listener based on the first operation instruction input by the user, the method further includes:
acquiring a browsing history of the browser;
and determining a target webpage based on the browsing history record and accessing the target webpage.
In one possible implementation manner, the registering a network event listener based on the first operation instruction input by the user includes:
and in response to a first operation instruction input by a user, establishing a communication transmission channel with the browser through a developer tool protocol so as to register the network event listener.
In a second aspect, an embodiment of the present application provides a network data acquisition device, which is applied to an extension program of a browser, and the device includes:
a registration module for registering the network event listener based on a first operation instruction input by a user;
the monitoring module is used for capturing the target network event of the browser based on the network event monitor;
and the analysis module is used for acquiring the HAR archive file of the network data corresponding to the target network event.
In one possible implementation, the apparatus further includes:
and the first removing module is used for removing the network event monitor based on a second operation instruction input by a user.
In one possible implementation, the apparatus further includes:
judging whether the current network event is an abnormal network event or not based on a preset rule;
and the second removing module is used for removing the network event monitor after the current network event is ended for a first duration under the condition that the current network event is an abnormal network event.
In one possible implementation manner, the second removing module includes:
the first judging unit is used for judging whether the network event monitor captures a network event in a second duration when the current network event is an abnormal network event;
the first execution unit is used for removing the network event monitor after the current network event ends the first time period if the network event monitor captures a network event in the second time period when the current network event ends;
wherein the second duration is less than the first duration.
In one possible implementation manner, the second removing module further includes:
and the second execution unit is used for removing the network event monitor after the second time period when the current network event ends if the network event monitor does not capture the network event in the second time period when the current network event ends.
In one possible implementation, the apparatus further includes:
the history module is used for acquiring the browsing history record of the browser;
and the access module is used for determining the target webpage based on the browsing history record and accessing the target webpage.
In one possible implementation manner, the registration module is specifically configured to:
and in response to a first operation instruction input by a user, establishing a communication transmission channel with the browser through a developer tool protocol so as to register the network event listener.
In one or more embodiments of the present application, registering a network event listener based on a first operation instruction input by a user; capturing a target network event of the browser based on the network event monitor; and acquiring HAR archive files of the network data corresponding to the target network events. According to the method and the device, the extended program of the browser is utilized, the monitoring of the target network event in the browser can be realized in response to the first operation instruction input by the user, the network data of the target network event can be rapidly and stably obtained, the HAR archive file can be directly obtained, and the subsequent diagnosis and analysis of the browser problem are facilitated. Meanwhile, the whole network data acquisition process is automatically carried out, the user operation is simple and convenient, the professional skill level of the user is not relied on, and the applicability is strong.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a network data acquisition method according to an exemplary embodiment of the present application;
FIG. 2 is a schematic diagram of an extended program interface according to an exemplary embodiment of the present application;
fig. 3 is a flowchart of a network data acquisition method according to an exemplary embodiment of the present application;
fig. 4 is a flowchart of a network data acquisition method according to an exemplary embodiment of the present application;
fig. 5 is a schematic structural diagram of a network data acquisition device according to an exemplary embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application.
Detailed Description
When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
In the description of the present application, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. The specific meaning of the terms in this application will be understood by those of ordinary skill in the art in a specific context. Furthermore, in the description of the present application, unless otherwise indicated, "a plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
It should be noted that, information (including but not limited to user equipment information, user personal information, etc.), data (including but not limited to data for analysis, stored data, presented data, etc.), and signals related to the embodiments of the present application are all authorized by the user or are fully authorized by the parties, and the collection, use, and processing of related data is required to comply with the relevant laws and regulations and standards of the relevant countries and regions. For example, browser network data and the like referred to in the present application are all acquired with sufficient authorization.
The present application is described in detail with reference to specific examples.
Embodiments of the present application provide a network data acquisition method, which may be implemented in dependence on a computer program, that may be run on a network data acquisition device based on von neumann systems. The computer program may be integrated in the application or may run as a stand-alone tool class application. The network data acquisition device in the embodiment of the present application may be a terminal device, including but not limited to: personal computers, tablet computers, handheld devices, vehicle mounted devices, wearable devices, computing devices, or other processing devices connected to a wireless modem, and the like. Terminal devices in different networks may be called different names, for example: a user equipment, an access terminal, a subscriber unit, a subscriber station, a mobile station, a remote terminal, a mobile device, a user terminal, a wireless communication device, a user agent or user equipment, a cellular telephone, a cordless telephone, a terminal device in a 5G network or a future evolution network, etc. The network data acquisition device may be a server, may be an independent physical server, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, a distribution network (Content Delivery Network, CDN), basic cloud computing services such as big data and an artificial intelligence platform. The network data acquisition device may also be a system of a combination of a server and a terminal device. The embodiment of the application is not limited to this, and is specifically determined based on the actual application environment.
The network data acquisition method provided in the present application is described in detail below with reference to specific embodiments.
Fig. 1 is a flowchart of a network data acquisition method according to an exemplary embodiment of the present application. As shown in fig. 1, the network data acquisition method uses a terminal device as an execution subject, and includes the following steps:
s101, registering a network event monitor based on a first operation instruction input by a user.
Specifically, the network data acquisition method provided in the present embodiment may be applied to an extension program (or component) of a browser. An extension is a small software application that is a plug-in or add-on to a browser that can be used to customize and enhance the functionality of a Web browser. For example, the extension program may allow the user to adjust the appearance of the browser, add new functionality, modify web page content, integrate third party services, etc., according to personal needs. The extension program may be developed using Web standard techniques (e.g., HTML, CSS, and JavaScript) and installed either locally or through the browser's official application store.
In this embodiment, the network event listener may be registered based on a first operation instruction input by the user. The first operation instruction may be an action triggered by the user through the browser extension interface to instruct the extension program to start a specific operation. By way of example, the first operating instruction may be clicking on a button, selecting a menu item, entering some data, or any other form of user input. For example, the user may click a button on the browser extension icon to register the network event listener to initiate network listening.
In this embodiment, the network event listener is a programmatic entity for monitoring and responding to network events (e.g., HTTP requests and responses). The network event monitor may register with a network interface of the browser to monitor and capture network requests and received responses issued by the browser in real time, thereby acquiring network data to support various network-related analysis and debugging functions.
In some embodiments, registering a network event listener based on a first operational instruction entered by a user includes: in response to a first operation instruction input by a user, a communication transmission channel is established with the browser through a developer tool protocol to register the network event listener.
Specifically, when it is required to start monitoring the network activity of the browser, the user may execute a first operation instruction in the interface of the extension program, for example, click a button or input a certain instruction, and the extension program may monitor the first operation instruction. When the user executes the first operation instruction, the extension program responds to the event and starts the flow of registering the network event listener. The procedure of registering the network event listener may include the steps of:
the extension program establishes a communication transmission channel with the browser using a developer tool protocol to set up a network event listener inside the browser. After the communication transmission channel is established, the extension program configures parameters of the network event monitor, and specifies the type of network event to be monitored, such as all HTTP requests and responses. The extension then activates or registers the network event listener. Once registration is complete, the network event listener begins capturing the browser's network events and corresponding network data in real-time and passing the data to the extension for processing and analysis.
Wherein the developer tool protocol is a set of interfaces provided by the browser that allow communication between the developer tool and the browser. This protocol allows the developer to programmatically control certain functions of the browser, such as checking elements, network monitoring, and debugging JavaScript, etc.
Illustratively, registering the network event listener in the Chrome browser may establish a communication transmission channel with the Chrome browser using the Chrome developer tool protocol, and in particular may register the network event listener using Chrome Debugger API (Application Programming Interface ). Chrome Debugger API is part of the Chrome developer tool protocol, dedicated to providing debug functionality. It allows an extension to access the debugging functions of the browser, such as setting breakpoints, checking call stacks, and listening for network events. Through the API, the extension program can control and access the debugging function of the Chrome browser in a programming mode, so that monitoring and capturing of network events are realized.
In this embodiment, the browser extension program initiates the network monitoring process by responding to the user's operation, establishes communication with the browser using the developer tool protocol (e.g., chrome Debugger API), and registers the network event listener to capture network activity, thereby enabling the extension program to capture rich network data for subsequent user network monitoring and analysis.
S102, capturing a target network event of the browser based on the network event monitor.
Specifically, the network event listener can capture the network event of the browser in real time after registration is completed. A web event is a web operation performed by a browser, such as a web request or a received response from the browser.
Wherein the network event may include:
HTTP request event: the HTTP request sent by the browser includes information such as URL (Uniform Resource Locator ) of the request, HTTP method (e.g. GET, POST), request header, sent data, etc.
HTTP response event: the server's response to the HTTP request includes a status code (e.g., 200, 404, 500, etc.), a response header, a response body, etc.
Request redirection event: the redirection of HTTP requests includes redirecting URLs and states before and after.
Resource loading events: the browser loads events of web page resources (e.g., pictures, scripts, CSS files, etc.).
By monitoring these network events, the extension program can collect detailed data about the user's network activities, facilitating network performance analysis, debugging, security monitoring of the browser.
In this embodiment, after the registration of the network event listener is completed, the network event of the browser can be captured in real time. The target network event represents a network event set which needs to be acquired by a user and comprises one or more network events and corresponding network data. The network data captured by the network event listener may be JavaScript objects that contain various details of the request and response, such as URLs, HTTP methods, header information, status codes, etc. In addition, in the Chrome browser, the network data captured by the network event listener may be NetLog format data, which is a format for recording network activity, providing detailed information about network events in the browser, including details of the request, timestamps, state changes during processing, and so forth. Whether the network data is captured in the form of JavaScript objects or NetLog format, the data can be further processed or analyzed by an extender for network performance assessment, problem diagnosis, or other network-related analysis tasks.
In some embodiments, after the network event listener captures the target network event of the browser, the method further includes:
and removing the network event monitor based on a second operation instruction input by the user.
Specifically, the second operation instruction may be an action triggered by the user through the browser extension interface, so as to instruct the extension program to start a specific operation. By way of example, the second operating instruction may be clicking on a button, selecting a menu item, entering some data, or any other form of user input. For example, the user may click a button on the browser extension icon to remove the network event listener to stop network listening. In this embodiment, the target network event, i.e., the network event listener captures a network event of the browser when the user inputs a first operation instruction and the user inputs a second operation instruction.
Illustratively, as shown in fig. 2, when a web problem occurs in the user browser, the web event listener may be registered by clicking a start button of the extended program interface to monitor the web activity of the browser in real time. The user may then reproduce the previously presented network problem, for example, access to a website where an abnormal problem occurs, or perform a corresponding operation instruction in the website, for example, input an account number, access to a certain tag web page, etc. After the network problem is reproduced, the network event monitor already monitors and captures the corresponding network event and network data, and in order to save the browser computing resources, the network event monitor can be removed and the monitoring of the network event can be stopped by clicking the end button of the extended program interface. The capturing of the target network event of the browser is completed, and the extension program can analyze the acquired target network event so as to analyze the network problem of the browser later.
In some embodiments, after registering the network event listener based on the first operation instruction input by the user, the method further includes:
acquiring a browsing history of a browser;
and determining a target webpage based on the browsing history record and accessing the target webpage.
Specifically, after the user inputs the first operation instruction to register the network event monitor, the extension program can automatically open and access a target webpage with possible abnormal problems according to the browsing history of the browser, so as to realize problem reproduction, and enable the network event monitor to capture corresponding network data. Therefore, the operation of the user can be further simplified, and the acquisition of the browser network data is more convenient.
For example, the extension may use a browser-provided history API (e.g., chrome. History API of Chrome) to access the user's browsing history. The history API extension program can acquire a webpage list recently accessed by the user, including information such as URL, access time and the like. The extension program may analyze the acquired browsing history and determine the target web pages to be reproduced based on criteria such as access frequency, time of last access, etc. After the target web page is determined, the extension program automatically opens the target web page in the browser, the previously registered network event listener will start capturing network activities of the target web page, and the user can perform interactive operations on the automatically opened target web page to try to reproduce possible problems, and at the same time, the network event listener will also continue capturing related network data.
S103, acquiring HAR archive files of network data corresponding to the target network event.
Specifically, the network event listener captures the network data of the target network event in real time in the browser, and the extender parses and organizes the captured network data into a structured form, and then converts the organized network data into a standardized file format, i.e., HAR (HTTP Archive) format. The HAR archive file is a JSON format file for recording detailed information of network requests and responses. The HAR archive may include information of the URL of the request, the request method, the request header, the request body, the response status code, the response header, the response body, etc. The HAR archive can be read and analyzed by various tools, so that diagnosis and debugging of network problems are more direct and efficient, and especially for scenes such as recognition of loading delay, optimization performance, analysis request failure and the like.
In some embodiments, the generated HAR archive file may be stored on the user's terminal device or provided to the user for download. The HAR archive file may also be sent to a server for further analysis.
In the embodiment of the application, a network event monitor is registered based on a first operation instruction input by a user; capturing a target network event of the browser based on the network event monitor; and acquiring HAR archive files of the network data corresponding to the target network events. According to the method and the device, the extended program of the browser is utilized, the monitoring of the target network event in the browser can be realized in response to the first operation instruction input by the user, the network data of the target network event can be rapidly and stably obtained, the HAR archive file can be directly obtained, and the subsequent diagnosis and analysis of the browser problem are facilitated. Meanwhile, the whole network data acquisition process is automatically carried out, the user operation is simple and convenient, the professional skill level of the user is not relied on, and the applicability is strong.
Referring next to fig. 3, fig. 3 illustrates a network data acquisition method according to an exemplary embodiment of the present application. As shown in fig. 3, the network data acquisition method uses the terminal device as an execution subject, and includes the following steps:
s301, registering a network event monitor based on a first operation instruction input by a user.
Specifically, the step S301 corresponds to the step S101, and will not be described herein.
S302, judging whether the current network event is an abnormal network event or not based on a preset rule.
Specifically, when an abnormal problem occurs in the browser, a user needs to enable the network event monitor to capture network events and network data for problem analysis. Therefore, the extension program in this embodiment can analyze the network event captured by the network event monitor in real time, and determine whether the network event belongs to an abnormal network event, so as to automatically end the network monitoring process, simplify the operation steps of the user, and save the computing resources of the browser.
In this embodiment, when the network event listener captures a network request or response, the extension program analyzes the events according to preset rules. If the event meets the anomaly pattern defined in the rule, it is marked as an anomaly network event. Abnormal network events refer to those network events that do not meet the expectations of normal network communications. The abnormal network events may be caused by network errors, server problems, resource loading failures, abnormal behavior of the application, etc. By identifying these unusual network events, it can help the developer locate and solve the network problems of the browser, optimizing the performance and stability of the browser. The preset rules are criteria or conditions used to identify abnormal network events. By way of example, the preset rules may be based on a variety of parameters, such as:
HTTP status code: such as the 4xx and 5xx series of status codes, typically represent client or server errors.
Response time: if the response time of a request exceeds a predetermined threshold, a performance problem is indicated.
Characteristics of the request or response body: such as a request failure, a returned data format error, or a content exception.
Request failure or timeout: the request cannot reach the server or is not responded to within a predetermined time.
The above preset rules are merely examples, and may be specifically set according to an actual implementation scenario in specific implementation, which is not limited herein.
S303, removing the network event monitor after the current network event is ended for a first time period in the case that the current network event is an abnormal network event.
Specifically, after the current network event is determined to be an abnormal network event, the extension program starts to count after the execution of the current network event is finished, waits for a predetermined first time period, and after the first time period expires, the network event listener is removed. The first duration is set to ensure that the network event monitor can capture all subsequent network activities related to the abnormal network event, thereby facilitating subsequent anomaly analysis and saving the computing resources of the browser to a certain extent.
In some embodiments, if the user does not succeed in reproducing the browser network problem, i.e., no abnormal network event occurs, the network monitor is removed after a third time period, where the third time period is longer than the first time period, so as to save computing resources of the browser and avoid the influence of running the network event monitor for a long time on the browser performance. In addition, the user can actively remove the network event monitor by inputting a second operation instruction, so that the operation of the network event monitor is more in line with the actual demands of the user.
S304, capturing a target network event of the browser based on the network event monitor.
Specifically, the target network event is a collection of network events captured during operation of the network event listener.
S305, acquiring HAR archive files of network data corresponding to the target network event.
Specifically, the step S305 corresponds to the step S103, and will not be described herein.
In the embodiment of the application, the user can complete the registration and removal of the network event monitor only by inputting the first operation instruction, realize the network data acquisition of the repeated network problem, and automatically convert the network data into the HAR archive file so as to feed back to the browser developer for corresponding problem analysis and repair. The whole network data acquisition process is automatically carried out, the user operation is simple and convenient, the user does not need to grasp the using skills of the developer tool, and the method is suitable for common users.
Referring next to fig. 4, fig. 4 illustrates a network data acquisition method according to an exemplary embodiment of the present application. As shown in fig. 4, the network data acquisition method uses the terminal device as an execution subject, and includes the following steps:
s401, registering a network event monitor based on a first operation instruction input by a user.
Specifically, the step S401 is identical to the step S101, and will not be described herein.
S402, judging whether the current network event is an abnormal network event based on a preset rule.
Specifically, the step S402 corresponds to the step S302, and will not be described herein.
S403, judging whether the network event monitor captures the network event in the second duration of ending the current network event under the condition that the current network event is an abnormal network event.
Specifically, if the network event listener captures a network event in the second duration of the end of the current network event, step S404 is performed.
If the network event listener does not capture a network event within the second duration of the end of the current network event, step S405 is performed.
S404, removing the network event monitor after the end of the first time period of the current network event.
Specifically, after the current network event is determined to be an abnormal network event, the extension program starts to time after the execution of the current network event is finished, waits for a predetermined second duration, and if the network event monitor captures the network event within the second duration, indicates that other network activities are behind the abnormal network event, and can remove the network event monitor after waiting for a predetermined first duration, wherein the second duration is less than the first duration, so that the acquired network data can be ensured to be more complete.
And S405, removing the network event monitor after the second duration of the current network event is finished.
Specifically, after the current network event is judged as an abnormal network event, the extension program starts to time after the execution of the current network event is finished, waits for a preset second time period, if the network event monitor does not capture the network event within the second time period, the network event monitor indicates that no other network activity exists behind the abnormal network event, the captured network data is complete, and the network event monitor can be removed directly after the end of the second time period so as to save the computing resources of the browser.
S406, capturing a target network event of the browser based on the network event listener.
Specifically, the target network event is a collection of network events captured during operation of the network event listener.
S407, acquiring the HAR archive file of the network data corresponding to the target network event.
Specifically, the step S407 corresponds to the step S103, and will not be described herein.
Referring next to fig. 5, fig. 5 is a diagram illustrating a network data acquisition device according to an exemplary embodiment of the present application. As shown in fig. 5, the network data acquisition apparatus 500 includes:
a registration module 510 for registering a network event listener based on a first operation instruction input by a user;
A listening module 520, configured to capture a target network event of the browser based on the network event listener;
the parsing module 530 is configured to obtain the HAR archive file of the network data corresponding to the target network event.
In some possible embodiments, the apparatus 500 further comprises:
and the first removing module is used for removing the network event monitor based on a second operation instruction input by a user.
In some possible embodiments, the apparatus 500 further comprises:
judging whether the current network event is an abnormal network event or not based on a preset rule;
and the second removing module is used for removing the network event monitor after the current network event is ended for a first duration under the condition that the current network event is an abnormal network event.
In some possible embodiments, the second removing module includes:
the first judging unit is used for judging whether the network event monitor captures a network event in a second duration when the current network event is an abnormal network event;
the first execution unit is used for removing the network event monitor after the current network event ends the first time period if the network event monitor captures a network event in the second time period when the current network event ends;
Wherein the second duration is less than the first duration.
In some possible embodiments, the second removing module further includes:
and the second execution unit is used for removing the network event monitor after the second time period when the current network event ends if the network event monitor does not capture the network event in the second time period when the current network event ends.
In some possible embodiments, the apparatus 500 further comprises:
the history module is used for acquiring the browsing history record of the browser;
and the access module is used for determining the target webpage based on the browsing history record and accessing the target webpage.
In some possible embodiments, the registration module 510 is specifically configured to:
and in response to a first operation instruction input by a user, establishing a communication transmission channel with the browser through a developer tool protocol so as to register the network event listener.
The above-mentioned division of each module in the network data acquisition device is only used for illustration, and in other embodiments, the network data acquisition device may be divided into different modules as needed to complete all or part of the functions of the network data acquisition device. The implementation of each module in the network data acquisition device provided in the embodiments of the present application may be in the form of a computer program. The computer program may run on a terminal or a server. Program modules of the computer program may be stored in the memory of the terminal or server. Which when executed by a processor, performs all or part of the steps of the network data acquisition method described in the embodiments of the present application.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present application. As shown in fig. 6, the electronic device 600 may include: at least one processor 610, at least one communication bus 620, a user interface 630, at least one network interface 640, a memory 650. Wherein the communication bus 620 may be used to enable the connection communication of the various components described above.
The user interface 630 may include a Display screen (Display) and a Camera (Camera), and the optional user interface may further include a standard wired interface and a wireless interface.
The network interface 640 may optionally include, among other things, a bluetooth module, a near field communication (Near Field Communication, NFC) module, a wireless fidelity (Wireless Fidelity, wi-Fi) module, and the like.
Wherein the processor 610 may include one or more processing cores. The processor 610 utilizes various interfaces and lines to connect various portions of the overall electronic device 600, perform various functions of the routing electronic device 600 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 650, and invoking data stored in the memory 650. Alternatively, the processor 610 may be implemented in hardware in at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 610 may integrate one or a combination of several of a processor (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into the processor 610 and may be implemented by a single chip.
The Memory 650 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (ROM). Optionally, the memory 650 includes a non-transitory computer readable medium. Memory 650 may be used to store instructions, programs, code, sets of codes, or sets of instructions. The memory 650 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a registration function, a listening function, etc.), instructions for implementing the various method embodiments described above, etc.; the storage data area may store data or the like referred to in the above respective method embodiments. Memory 650 may also optionally be at least one storage device located remotely from the aforementioned processor 610. As shown in fig. 6, an operating system, network communication modules, user interface modules, and program instructions may be included in memory 650, which is a type of computer storage medium.
In particular, the processor 610 may be configured to invoke the program instructions stored in the memory 650 and to perform in particular the following operations:
registering a network event listener based on a first operation instruction input by a user;
Capturing a target network event of the browser based on the network event monitor;
and acquiring HAR archive files of the network data corresponding to the target network events.
In some possible embodiments, the processor 610 is further specifically configured to, after executing the capturing, by the network event listener, the target network event of the browser, execute:
and removing the network event monitor based on a second operation instruction input by the user.
In some possible embodiments, the processor 610 is further specifically configured to, after executing the first operation instruction based on the user input, register the network event listener, perform:
judging whether the current network event is an abnormal network event or not based on a preset rule;
and removing the network event monitor after the current network event ends the first duration under the condition that the current network event is an abnormal network event.
In some possible embodiments, the processor 610 is configured to, when executing the case where the current network event is an abnormal network event and removing the network event listener after the end of the first duration of the current network event, execute:
Judging whether the network event monitor captures a network event in a second duration when the current network event is ended under the condition that the current network event is an abnormal network event;
if the network event monitor captures a network event in the second time period when the current network event ends, removing the network event monitor after the first time period when the current network event ends;
wherein the second duration is less than the first duration.
In some possible embodiments, the processor 610 is further specifically configured to, after executing the determining whether the network event listener captures a network event in the second duration of the end of the current network event, execute:
and if the network event monitor does not capture the network event in the second time period when the current network event is ended, removing the network event monitor after the second time period when the current network event is ended.
In some possible embodiments, the processor 610 is further specifically configured to, after executing the first operation instruction based on the user input, register the network event listener, perform:
acquiring a browsing history of the browser;
And determining a target webpage based on the browsing history record and accessing the target webpage.
In some possible embodiments, the processor 610, when executing the first operation instruction based on the user input to register the network event listener, is specifically configured to execute:
and in response to a first operation instruction input by a user, establishing a communication transmission channel with the browser through a developer tool protocol so as to register the network event listener.
Embodiments also provide a computer readable storage medium having instructions stored therein, which when run on a computer or processor, cause the computer or processor to perform one or more steps of the above embodiments. The respective constituent modules of the network data acquisition device may be stored in the computer-readable storage medium if implemented in the form of software functional units and sold or used as independent products.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product described above includes one or more computer instructions. When the above-described computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted across a computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage media may be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy Disk, a hard Disk, a magnetic tape), an optical medium (e.g., a digital versatile Disk (Digital Versatile Disc, DVD)), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
Those skilled in the art will appreciate that implementing all or part of the above-described embodiment methods may be accomplished by way of a computer program, which may be stored in a computer-readable storage medium, instructing relevant hardware, and which, when executed, may comprise the embodiment methods as described above. And the aforementioned storage medium includes: various media capable of storing program code, such as ROM, RAM, magnetic or optical disks. The technical features in the present examples and embodiments may be arbitrarily combined without conflict.
The above-described embodiments are merely illustrative of the preferred embodiments of the present application and are not intended to limit the scope of the present application, and various modifications and improvements made by those skilled in the art to the technical solutions of the present application should fall within the scope of protection defined by the claims without departing from the design spirit of the present application.
The foregoing describes specific embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims and description may be performed in an order different from that in the embodiments recited in the description and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

Claims (10)

1. A method for acquiring network data, characterized by an extension program applied to a browser, the method comprising:
registering a network event listener based on a first operation instruction input by a user;
capturing a target network event of the browser based on the network event listener;
and acquiring the HAR archive file of the network data corresponding to the target network event.
2. The method of claim 1, wherein after the capturing the target network event of the browser based on the network event listener, the method further comprises:
the network event listener is removed based on a second operational instruction entered by the user.
3. The method of claim 1, wherein after registering a network event listener based on the first operation instruction entered by the user, the method further comprises:
judging whether the current network event is an abnormal network event or not based on a preset rule;
and removing the network event monitor after the current network event ends for a first duration under the condition that the current network event is an abnormal network event.
4. The method of claim 3, wherein, in the case where the current network event is an abnormal network event, removing the network event listener after the current network event ends for a first duration comprises:
Judging whether the network event monitor captures a network event in a second duration when the current network event is an abnormal network event;
if the network event monitor captures a network event in a second time period when the current network event is ended, removing the network event monitor after the first time period when the current network event is ended;
wherein the second duration is less than the first duration.
5. The method of claim 4, wherein the determining whether the network event listener captured a network event within a second duration of the end of the current network event further comprises:
and if the network event monitor does not capture the network event in the second time period when the current network event is ended, removing the network event monitor after the second time period when the current network event is ended.
6. The method of claim 1, wherein after registering a network event listener based on the first operation instruction entered by the user, the method further comprises:
acquiring a browsing history of the browser;
And determining a target webpage based on the browsing history record and accessing the target webpage.
7. The method of claim 1, wherein the registering a network event listener based on the first operation instruction entered by the user comprises:
and in response to a first operation instruction input by a user, establishing a communication transmission channel with the browser through a developer tool protocol so as to register the network event listener.
8. A network data acquisition apparatus, characterized by an extension program applied to a browser, comprising:
a registration module for registering the network event listener based on a first operation instruction input by a user;
a monitoring module, configured to capture a target network event of the browser based on the network event monitor;
and the analysis module is used for acquiring the HAR archive file of the network data corresponding to the target network event.
9. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the method steps of any of claims 1-7.
10. An electronic device, comprising: a processor and a memory;
the processor is connected with the memory; the memory is used for storing executable program codes;
The processor runs a program corresponding to executable program code stored in the memory by reading the executable program code for performing the method steps of any one of claims 1-7.
CN202311755846.1A 2023-12-19 2023-12-19 Network data acquisition method, device, medium and equipment Pending CN117762668A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311755846.1A CN117762668A (en) 2023-12-19 2023-12-19 Network data acquisition method, device, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311755846.1A CN117762668A (en) 2023-12-19 2023-12-19 Network data acquisition method, device, medium and equipment

Publications (1)

Publication Number Publication Date
CN117762668A true CN117762668A (en) 2024-03-26

Family

ID=90322995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311755846.1A Pending CN117762668A (en) 2023-12-19 2023-12-19 Network data acquisition method, device, medium and equipment

Country Status (1)

Country Link
CN (1) CN117762668A (en)

Similar Documents

Publication Publication Date Title
CN109739717B (en) Page data acquisition method and device and server
CN107294808B (en) Interface test method, device and system
US20230344914A1 (en) Scene pushing method, scene executing method, scene pushing device, scene executing device, terminal, server and system
CN107948744B (en) Interface detection method, interface detection device, and computer-readable storage medium
CN111897724B (en) Automatic testing method and device suitable for cloud platform
WO2010092585A1 (en) A system, a method and a computer program product for automated remote control
CN110798380B (en) Data acquisition method, system, device, test equipment and test server
CN105607986A (en) Acquisition method and device of user behavior log data
CN107644075B (en) Method and device for collecting page information
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
CN112583898A (en) Business process arranging method and device and readable medium
CN113422794A (en) Traffic recording and playback processing method and device and electronic equipment
CN109828920A (en) A kind of log analysis method, device and computer readable storage medium
CN111597065A (en) Method and device for collecting equipment information
CN109542754B (en) Access method of mobile equipment, debugging method, device and system of application program
US10140377B2 (en) Data processing, data collection
CN112948224A (en) Data processing method, device, terminal and storage medium
CN108039956A (en) Using monitoring method, system and computer-readable recording medium
CN114217803A (en) Page function problem processing method and device and electronic equipment
CN115996179A (en) Service node testing method and device, readable medium and electronic equipment
CN114285774B (en) Flow recording method and device, electronic equipment and storage medium
CN117762668A (en) Network data acquisition method, device, medium and equipment
CN109756393B (en) Information processing method, system, medium, and computing device
CN114092169A (en) Ordering test method and system and equipment for executing ordering test method
CN113542796B (en) Video evaluation method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination