Page state determination method and device, storage medium and electronic device
Patent Information
- Application Number
- CN202310134042.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-08
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2043-02-08
AI Technical Summary
[0006]本发明实施例提供了一种页面状态的确定方法及装置、存储介质及电子装置,以至少解决对于使用单页面框架开发的网页而言,无法快速检测网页中的页面的状态的问题
[0017]通过本发明,在第一标签页上通过目标网页的统一资源定位符URL访问目标网页,并获取目标网页的路由对象集合;在第二标签页上访问路由对象集合中每个子路由对应的子页面,并确定所述每个子路由对应的子页面的状态。也就是说,本发明在新的标签页上访问路由对象集合中每个子路由对应的子页面,并确定每个子路由对应的子页面的页面状态,避免了对于使用单页面框架开发的网页而言,需要人工检测网页中的页面的状态,提高了检测效率,解决了对于使用单页面框架开发的网页而言,无法快速检测网页中的页面的状态的问题。
Smart Images

Figure CN116304455B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of smart home, in particular to a page state determination method and device, a storage medium and an electronic device. BACKGROUND
[0002] Generally, a web page has a main page and multiple sub-pages, and as the business grows, the sub-pages become more and more, and each time the web page has a new function online (that is, the original page will be changed or a sub-page will be added), the web page needs to be detected to determine whether there is a 404 page in the web page. If the detection is performed manually, it is a very time-consuming and error-prone thing.
[0003] Most of the current page detection technologies use the crawling method, using the request library or the axios library, simulating the request request according to the current page URL, obtaining the html file of the target page. Through the analysis and processing of the html file, the target content is obtained. The crawling method can deal with multi-page applications (that is, the web page is developed using a multi-page framework, and each page of the web page has a corresponding html file), but if it is a single-page application (that is, the web page is developed using a single-page framework, and all pages of the web page correspond to an html file), the obtained html file will not change. The entry file of the web page using the single-page application framework is only an index.html, and when clicking the menu component to jump to different pages, the internal routing redirection method is used, that is, if the page routing changes, the browser will not perform request forwarding or page redirection, but according to the routing change, the content is loaded to replace some DOM elements. In this case, if the above-mentioned crawling technology is used, the obtained html file is always index.html, and the content will not change, and it is also impossible to detect which sub-menu component corresponds to the 404 page.
[0004] For the problem that the web page developed using the single-page framework cannot quickly detect the state of the page in the web page in the related art, there is no effective solution at present.
[0005] Therefore, it is necessary to improve the related art to overcome the defects in the related art. SUMMARY
[0006] The embodiments of the present application provide a page state determination method and device, a storage medium and an electronic device to at least solve the problem that the web page developed using the single-page framework cannot quickly detect the state of the page in the web page.
[0007] According to an aspect of an embodiment of the present application, a method for determining a page state is provided. The method includes: obtaining a uniform resource locator (URL) of a target webpage; accessing the target webpage through the URL on a first tab page and obtaining a route object set of the target webpage, wherein the route object set includes a plurality of sub-routes, each of the plurality of sub-routes is used to switch from a main page of the target webpage to a sub-page corresponding to the each sub-route; and accessing the sub-page corresponding to each sub-route in the route object set on a second tab page and determining a state of the sub-page corresponding to each sub-route.
[0008] In an example embodiment, obtaining the route object set of the target webpage includes: intercepting a plurality of request messages, and determining a route interface from a plurality of interfaces of the target webpage according to the plurality of request messages, wherein each of the plurality of request messages is used to access one of the plurality of interfaces; obtaining return information of the route interface returned by a server of the target webpage, and obtaining the route object set of the target webpage from the return information.
[0009] In an example embodiment, before intercepting the plurality of request messages, the method further includes: logging in the target webpage using a target account, and storing text data corresponding to the target account obtained to a browser, wherein the server of the target webpage identifies the target account according to the text data; and controlling the browser to send the plurality of request messages to the server of the target webpage.
[0010] In an example embodiment, accessing the sub-page corresponding to each sub-route in the route object set on the second tab page includes: splicing the each sub-route with the URL to obtain a page link corresponding to the each sub-route; and accessing the sub-page corresponding to the each sub-route on the second tab page through the page link corresponding to the each sub-route.
[0011] In an example embodiment, determining the state of the sub-page corresponding to each sub-route includes: in a case that a first sub-route corresponding sub-page is currently accessed through the second tab page, obtaining an attribute value of a target attribute in a Window object of a browser, wherein the first sub-route is any one of the route object set; in a case that the attribute value has a target identifier, determining that the state of the first sub-route corresponding sub-page is an abnormal state; and in a case that the attribute value does not have the target identifier, determining that the state of the first sub-route corresponding sub-page is a normal state.
[0012] In an example embodiment, after determining the state of the sub-page corresponding to each sub-route, the method further comprises: in a case where the state of the sub-page corresponding to the second sub-route is an abnormal state, determining a component name of a component in the target web page corresponding to the second sub-route, wherein the second sub-route is one of the set of route objects; storing a correspondence between the second sub-route and the component name, and a target picture, wherein the target picture is a picture of the second tab page captured in a case where the sub-page corresponding to the second sub-route is accessed on the second tab page.
[0013] In an example embodiment, accessing the sub-page corresponding to each sub-route in the set of route objects on the second tab page comprises: determining a first number of tabs allowed to be opened simultaneously by the browser; creating a second number of second tab pages, and accessing the sub-page corresponding to the second number of sub-routes in the set of route objects on the second number of second tab pages respectively each time until the sub-page corresponding to each sub-route in the set of route objects is accessed, wherein the first number is equal to the second number plus one.
[0014] According to another aspect of the embodiments of the present application, there is also provided a page state determination apparatus, comprising: a first obtaining module configured to obtain a uniform resource locator (URL) of a target web page; a second obtaining module configured to access the target web page through the URL on a first tab page, and obtain a set of route objects of the target web page, wherein the set of route objects comprises a plurality of sub-routes, each of the plurality of sub-routes being used to switch from a main page of the target web page to a sub-page corresponding to the sub-route; and a determining module configured to access the sub-page corresponding to each sub-route in the set of route objects on a second tab page, and determine a state of the sub-page corresponding to each sub-route.
[0015] According to yet another aspect of the embodiments of the present application, there is also provided a computer readable storage medium having a computer program stored therein, wherein the computer program is configured to perform the above-described page state determination method when running.
[0016] According to yet another aspect of the embodiments of the present application, there is also provided an electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor performs the above-described page state determination method through the computer program.
[0017] By the present application, the target webpage is accessed by a uniform resource locator URL of the target webpage on the first tab page, and a route object set of the target webpage is acquired; each sub-page corresponding to each sub-route in the route object set is accessed on the second tab page, and the state of each sub-page corresponding to each sub-route is determined. That is, each sub-page corresponding to each sub-route in the route object set is accessed on a new tab page, and the state of each sub-page corresponding to each sub-route is determined, which avoids the need for manual detection of the state of the page in the webpage for the webpage developed using a single-page framework, improves the detection efficiency, and solves the problem that the state of the page in the webpage cannot be quickly detected for the webpage developed using a single-page framework. BRIEF DESCRIPTION OF DRAWINGS
[0018] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the present application.
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings required to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.
[0020] Figure 1 Fig. 1 is a hardware environment schematic diagram of a page state determination method according to an embodiment of the present application;
[0021] Figure 2 Fig. 2 is a flowchart of a page state determination method according to an embodiment of the present application;
[0022] Figure 3 Fig. 3 is a flowchart of a page state determination method according to an embodiment of the present application;
[0023] Figure 4 Fig. 4 is a structural block diagram of a page state determination device according to an embodiment of the present application (1);
[0024] Figure 5 Fig. 5 is a structural block diagram of a page state determination device according to an embodiment of the present application (2). DETAILED DESCRIPTION
[0025] In the following, the technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application, so that those skilled in the art can better understand the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] According to an aspect of the embodiments of the present application, a page state determination method is provided. The page state determination method is widely used in smart home, smart home, smart home device ecosystem, intelligence house ecosystem and other whole-house intelligent digital control application scenarios. Optionally, in the present embodiment, the above-mentioned page state determination method can be applied to the hardware environment composed of terminal device 102 and server 104 as shown in Figure 1 As shown in Figure 1 The server 104 is connected with the terminal device 102 through the network, which can be used to provide services (such as application services, etc.) for the terminal or the client installed on the terminal, a database can be set on the server or independently of the server, which can be used to provide data storage services for the server 104, cloud computing and / or edge computing services can be configured on the server or independently of the server, which can be used to provide data operation services for the server 104.
[0028] The network can include, but is not limited to, at least one of the following: a wired network, a wireless network. The wired network can include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, a local area network. The wireless network can include, but is not limited to, at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 can include, but is not limited to, a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart oven, a smart refrigerator, a smart oven, a smart oven, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart television, a smart clothesline, a smart curtain, a smart audio and video, a smart socket, a smart sound, a smart sound box, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0029] To solve the above problems, in the present embodiment, a page state determination method is provided, which includes but is not limited to being applied in a script (in the case of running in a node environment, the following steps are automatically executed), Figure 2 is a flowchart of a page state determination method according to an embodiment of the present application, which includes the following steps:
[0030] Step S202, obtaining a uniform resource locator URL of a target webpage;
[0031] As an optional example, the target webpage can be a webpage of a shopping mall, for example, a certain shopping mall, wherein the target webpage has a main page, and according to different content or functions, the target webpage can also have multiple subpages, and the main page has a jump component (menu) for switching to the subpage, for example, the main page has 137 menus, and the target webpage can have 137 subpages.
[0032] Step S204, accessing the target webpage through the URL on the first tab page, and obtaining a route object set of the target webpage, wherein the route object set includes multiple sub-routes, and each sub-route in the multiple sub-routes is used to switch from the main page of the target webpage to the sub-page corresponding to each sub-route;
[0033] It should be noted that the tab page in the present application is a tab page in the browser, that is, the target webpage is accessed through the URL of the target webpage on the first tab page of the browser.
[0034] In an exemplary embodiment, the above-mentioned obtaining the route object set of the target webpage can be realized by the following steps S11-S12:
[0035] Step S11: intercepting a plurality of request messages, and determining a routing interface from a plurality of interfaces of the target webpage according to the plurality of request messages, wherein each of the plurality of request messages is used to access one of the plurality of interfaces;
[0036] Step S12: obtaining return information of the routing interface returned by a server of the target webpage, and obtaining a routing object set of the target webpage from the return information.
[0037] It should be noted that the purpose of the above steps S11-S12 is to obtain the routes of all jump components (menus) of the target webpage from an interface. Because when the target webpage is opened, there is an interface that can obtain the routes corresponding to all jump components, and then after the target webpage is opened, the request messages of all these interfaces can be intercepted, and the routing interface that can return the routing object set is matched according to the regular expression, and the routing object set is obtained from the response object of the routing interface after matching.
[0038] In an exemplary embodiment, before intercepting a plurality of request messages, the following steps S21-S22 are further included:
[0039] Step S21: logging in to the target webpage using a target account, and storing the obtained text data corresponding to the target account to a browser, wherein a server of the target webpage identifies the target account according to the text data;
[0040] As an optional example, the text data is a cookie.
[0041] Step S22: controlling the browser to send the plurality of request messages to the server of the target webpage.
[0042] As an optional example, since the routing interface is determined by intercepting the request message, the browser needs to be controlled to send the plurality of request messages to the server of the target webpage.
[0043] It should be noted that after the script opens the browser, a browser instance can be returned, and then the browser instance is used to open a specific page (for example, a main page). The difference between the embodiment and the normal access to the target page is that a layer of logic is built on the browser to control the behavior of the browser. The cookie is generated when the target webpage is accessed, and is not controlled by the script. The script in the embodiment is only responsible for controlling the behavior of the browser, such as opening the webpage, simulating the click event to automatically fill in the username and password, and intercepting the request.
[0044] Step S206, accessing the sub-page corresponding to each sub-route in the route object set on the second tab page, and determining the state of the sub-page corresponding to each sub-route.
[0045] It should be noted that the second tab page of the embodiment of the present application is a tab page different from the first tab page. As an optional example, as long as the tab page different from the first tab page can be referred to as the second tab page.
[0046] In an exemplary embodiment, the above-mentioned accessing the sub-page corresponding to each sub-route in the route object set on the second tab page can be implemented by the following steps S31-S32:
[0047] Step S31: Splicing the URL with each sub-route to obtain the page link corresponding to each sub-route;
[0048] Step S32: Accessing the sub-page corresponding to each sub-route on the second tab page through the page link corresponding to each sub-route.
[0049] In an exemplary embodiment, the above-mentioned determining the state of the sub-page corresponding to each sub-route can be implemented by the following steps S41-S43:
[0050] Step S41: In the case that the first sub-route corresponding sub-page is currently accessed through the second tab page, obtaining the attribute value of the target attribute in the Window object of the browser, wherein the first sub-route is any one sub-route in the route object set;
[0051] It should be noted that the target attribute is location.href, which points to the address bar of the current browser. If it is a normal URL request, the browser address bar will display the URL; if it is a non-existent URL, the target web page will automatically redirect to the 404 page, at this time the URL of the browser address bar will end with 404, and the state of the first sub-route corresponding sub-page is determined according to the same;
[0052] Step S42: In the case that the attribute value has a target identifier, determining that the state of the first sub-route corresponding sub-page is an abnormal state;
[0053] It should be noted that the target identifier is 404. The abnormal state includes the page being 404.
[0054] Step S43: In the case that the attribute value does not have the target identifier, determining that the state of the first sub-route corresponding sub-page is a normal state.
[0055] As an optional example, in a case that the first sub-page corresponding to the first sub-route is currently accessed through the second tab page, and it is determined that the state of the first sub-page corresponding to the first sub-route is the abnormal state, the second tab page is screenshot and closed, and in a case that the next sub-page corresponding to the next sub-route is accessed, a tab page is re-opened.
[0056] In an exemplary embodiment, after determining the state of each sub-page corresponding to each sub-route, the following steps S51-S52 are further included:
[0057] Step S51: In a case that the state of the second sub-page corresponding to the second sub-route is the abnormal state, determining a component name of a component in the target web page corresponding to the second sub-route, wherein the second sub-route is one sub-route in the route object set;
[0058] Step S52: Storing a correspondence between the second sub-route and the component name, and a target picture, wherein the target picture is a picture of the second tab page in a case that the second sub-page corresponding to the second sub-route is accessed on the second tab page.
[0059] That is, if the second sub-route corresponds to a 404 page, the second sub-route and the corresponding jump component name (menu name) of the second sub-route on the main page of the target web page are stored (optionally, they can be stored in a map), and a screenshot of the second tab page in a case that the second sub-route is currently accessed is stored, so as to facilitate subsequent personnel to review.
[0060] In an exemplary embodiment, the above-mentioned accessing each sub-page corresponding to each sub-route in the route object set on the second tab page can be achieved by the following steps S61-S62:
[0061] Step S61: Determining a first number of tabs that the browser is allowed to open simultaneously;
[0062] Step S62: Newing a second number of second tab pages, and accessing each sub-page corresponding to each of the second number of sub-routes in the route object set on the second number of second tab pages respectively each time until each sub-page corresponding to each sub-route in the route object set is accessed, wherein the first number is equal to the second number plus one.
[0063] It should be noted that since too many tabs are opened simultaneously, the browser may be crashed, and thus the first number of tabs that the browser can open simultaneously can be determined, and then a second number of tabs are newly created (the first tab always exists) simultaneously, and sub-pages corresponding to the second number of sub-routes are accessed simultaneously, and thus the detection efficiency can be improved.
[0064] In one exemplary embodiment, after a second tab page is newly created to access a page corresponding to a sub-route, the page state of the page is determined, the tab page is closed, and a new tab page is created to access a page corresponding to a next sub-route.
[0065] Through the above steps, the target web page is accessed through a uniform resource locator (URL) of the target web page on the first tab page, and a route object set of the target web page is obtained; each sub-route corresponding sub-page in the route object set is accessed on the second tab page, and the state of each sub-route corresponding sub-page is determined. That is, by accessing each sub-route corresponding sub-page in the route object set on a new tab page and determining the page state of each sub-route corresponding sub-page, the need for manual detection of the state of the page in the web page developed using a single-page framework is avoided, the detection efficiency is improved, and the problem that the state of the page in the web page developed using a single-page framework cannot be quickly detected is solved.
[0066] Obviously, the above-described embodiments are only part of the embodiments of the present application, not all. In order to better understand the above method, the above process is described below in combination with the embodiments, but not used to limit the technical solutions of the embodiments of the present application, specifically:
[0067] In one optional embodiment, Figure 3 is a flowchart of a page state determination method according to an embodiment of the present application, which is applied in a script (when the script is run in a node environment, the above steps will be automatically executed), specifically, having the following steps:
[0068] Step 1, start the browser and access the merchant center website (equivalent to the above target web page);
[0069] Step 2, simulate automatic login of the user, and store the cookie in the browser;
[0070] Step 3, intercept all request requests, use regular matching to route interface, and get route objects (equivalent to the route object set in the above embodiment) from response, the route objects include all sub-routes of the merchant center, i.e. each sub-menu (equivalent to the jump component in the above embodiment) corresponding sub-route;
[0071] Step 4, process the obtained route objects, and sequentially splice each sub-route and the domain name of the merchant center into a complete url link and store it in the array routes;
[0072] Step 5, automatically open a new tab page (equivalent to the second tab page described above), and access the first link of routes, wait for all requests in the page to be loaded;
[0073] Step 6, get location.href from the window object of the browser, which points to the address bar of the current browser. If it is a normal URL request of the merchant center, the browser address bar will display the URL under the merchant center domain name; if it is a non-existent URL, the merchant center will automatically redirect to the 404 page, at which time the URL of the browser address bar will end with 404, and the menu is determined whether 404;
[0074] Step 7, after getting the URL, it is determined whether it is "404" ending, if it is "404" ending, the menu name and URL corresponding to the URL in routes are stored in the map object, the current tab page is captured and saved in the local folder set in advance, and the tab page of the browser is closed;
[0075] Step 8, if the number of sub-routes is too large, opening many tabs at a time will cause the browser to crash. Therefore, recursion is used for asynchronous control, and the next tab page is opened only after the current tab page is closed, to prevent the browser from crashing;
[0076] Step 9, repeat steps 5, 6 and 7 until all sub-routes are accessed;
[0077] Step 10, export the name and route of all 404 menus to excel.
[0078] In short, the present application simulates user login by writing JavaScript scripts, obtains cookies, intercepts the route menu interface, splices the multiple sub-routes returned by the interface, controls the browser to open a new tab page to access each sub-route in a loop, and then gets the sub-route through the browser's location.href attribute. If a sub-route does not exist, the merchant center will use the internal route redirection method to redirect to the merchant center 404 page, so that the sub-route obtained by the browser's location.href will have a / 404 suffix, and the suffix is used to determine whether a specific menu corresponds to a 404 page.
[0079] That is, in the embodiment, a merchant center-based monitoring technology of a SPA page sub-route 404 is provided. The problem that a web crawler cannot determine whether an SPA page is 404 is solved in the case of internal redirection of an SPA route, the crawled html of the web crawler is unchanged, and manual detection is replaced by automatic opening of all sub-menus to determine whether it is 404, the sub-menus of 404 are exported into an excel table, and screenshots are taken as supplements, without manual operation.
[0080] Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and necessary general hardware platforms, and of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, or optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the method of each embodiment of the present application.
[0081] In the embodiment, a page state determination apparatus is also provided, which is used to implement the above embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.
[0082] Figure 4 A structural block diagram of a page state determination apparatus according to an embodiment of the present application (one) is shown in FIG. 1. The apparatus includes:
[0083] A first acquisition module 42 is configured to acquire a uniform resource locator (URL) of a target web page.
[0084] A second acquisition module 44 is configured to access the target web page through the URL on a first tab page and acquire a route object set of the target web page, wherein the route object set includes a plurality of sub-routes, each of the plurality of sub-routes being used to switch from a main page of the target web page to a sub-page corresponding to the each sub-route.
[0085] A determination module 46 is configured to access the sub-page corresponding to each sub-route in the route object set on a second tab page and determine a state of the sub-page corresponding to each sub-route.
[0086] The device is used for accessing a target webpage on a first tab page through a uniform resource locator (URL) of the target webpage, obtaining a route object set of the target webpage, accessing a subpage corresponding to each sub-route in the route object set on a second tab page, and determining a state of the subpage corresponding to each sub-route. In other words, by accessing the subpage corresponding to each sub-route in the route object set on a new tab page and determining the state of the subpage corresponding to each sub-route, the device avoids the need for manual detection of the state of a page in a webpage developed by using a single-page framework, improves the detection efficiency, and solves the problem that the state of a page in a webpage developed by using a single-page framework cannot be quickly detected.
[0087] In an example embodiment, the second obtaining module is further configured to intercept a plurality of request messages, determine a routing interface from a plurality of interfaces of the target webpage according to the plurality of request messages, wherein each request message in the plurality of request messages is used to access one interface in the plurality of interfaces, obtain return information of the routing interface returned by a server of the target webpage, and obtain a route object set of the target webpage from the return information.
[0088] In an example embodiment, Figure 5 is a structural block diagram of a page state determination device according to an embodiment of the present application (II), as Figure 5 shown in the figure, the device further includes a control module 48 configured to log in to the target webpage using a target account before intercepting a plurality of request messages, and store text data corresponding to the target account obtained to a browser, wherein a server of the target webpage identifies the target account according to the text data, and the control module 48 is configured to control the browser to send the plurality of request messages to the server of the target webpage.
[0089] In an example embodiment, the determination module includes a first access unit configured to splice the URL and each sub-route to obtain a page link corresponding to each sub-route, and access the subpage corresponding to each sub-route on the second tab page through the page link corresponding to each sub-route.
[0090] In an example embodiment, the determination module includes a determination unit configured to, in a case where a first sub-route corresponding subpage is currently accessed through the second tab page, obtain an attribute value of a target attribute in a Window object of a browser, wherein the first sub-route is any one sub-route in the route object set, determine that the state of the first sub-route corresponding subpage is an abnormal state in a case where the attribute value has a target identifier, and determine that the state of the first sub-route corresponding subpage is a normal state in a case where the attribute value does not have the target identifier.
[0091] In one example embodiment, as shown in Figure 5 The device further includes a storage module 50 configured to determine a component name of a component corresponding to a second sub-route in the target webpage, in a case where a state of a sub-page corresponding to the second sub-route is an abnormal state, after determining the state of the sub-page corresponding to each sub-route, wherein the second sub-route is one of the set of route objects; and store a correspondence between the second sub-route and the component name, and a target picture, wherein the target picture is a picture of the second tab page captured in a case where the sub-page corresponding to the second sub-route is accessed on the second tab page.
[0092] In one example embodiment, the determining module includes a second accessing unit configured to determine a first number of tabs allowed to be simultaneously opened by the browser; create a second number of second tabs, and access a sub-page corresponding to each of the second number of sub-routes in the set of route objects on the second number of second tabs respectively each time until the sub-page corresponding to each of the sub-routes in the set of route objects is accessed, wherein the first number is equal to the second number plus one.
[0093] Embodiments of the present application also provide a computer readable storage medium having a computer program stored therein, wherein the computer program is configured to execute the steps in any of the method embodiments described above when running.
[0094] Optionally, in the present embodiment, the storage medium can be configured to store a computer program for executing the following steps:
[0095] S1, obtaining a uniform resource locator (URL) of a target webpage;
[0096] S2, accessing the target webpage on a first tab page through the URL, and obtaining a set of route objects of the target webpage, wherein the set of route objects includes a plurality of sub-routes, each of the plurality of sub-routes being used to switch from a main page of the target webpage to a sub-page corresponding to each sub-route;
[0097] S3, accessing the sub-page corresponding to each sub-route in the set of route objects on a second tab page, and determining a state of the sub-page corresponding to each sub-route.
[0098] In an example embodiment, the computer readable storage medium described above can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0099] The specific examples in the present embodiment can refer to the examples described in the above embodiments and example embodiments, which will not be repeated here.
[0100] The embodiments of the present application also provide an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the above method embodiments.
[0101] Optionally, in the present embodiment, the processor can be configured to execute the following steps through the computer program:
[0102] S1, obtaining a uniform resource locator (URL) of a target webpage;
[0103] S2, accessing the target webpage through the URL on a first tab page, and obtaining a route object set of the target webpage, wherein the route object set includes a plurality of sub-routes, and each sub-route in the plurality of sub-routes is used to switch from a main page of the target webpage to a sub-page corresponding to the each sub-route;
[0104] S3, accessing the sub-page corresponding to each sub-route in the route object set on a second tab page, and determining the state of the sub-page corresponding to each sub-route.
[0105] In an example embodiment, the electronic device described above can further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0106] The specific examples in the present embodiment can refer to the examples described in the above embodiments and example embodiments, which will not be repeated here.
[0107] It is apparent that those skilled in the art can, without departing from the spirit of the present application, make various changes and modifications of the modules or steps of the present application described above, which can be implemented by general computing devices, and can be centralized on a single computing device or distributed on a network composed of multiple computing devices, and can be implemented by program codes executable by the computing devices, so that they can be stored in storage devices and executed by the computing devices, and in some cases, the steps shown or described can be executed in different orders, or can be made into individual integrated circuit modules, or a plurality of modules or steps can be made into a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.
[0108] The above description is merely preferred embodiments of the present application, and it should be pointed out that those skilled in the art can make several improvements and refinements without departing from the principles of the present application, and these improvements and refinements should be considered as the protection scope of the present application.
Claims
1. A method for determining page state, characterized in that, include: Obtain the Uniform Resource Locator (URL) of the target webpage; Access the target webpage via the URL on the first tab and obtain a set of route objects for the target webpage, wherein the set of route objects includes multiple sub-routes, and each sub-route is used to switch from the main page of the target webpage to the sub-page corresponding to each sub-route; Access the sub-page corresponding to each sub-route in the set of route objects on the second tab, and determine the state of the sub-page corresponding to each sub-route; Accessing the sub-page corresponding to each sub-route in the set of routing objects on the second tab includes: concatenating each sub-route with the URL to obtain the page link corresponding to each sub-route; and accessing the sub-page corresponding to each sub-route on the second tab through the page link corresponding to each sub-route. The determination of the state of the subpage corresponding to each sub-route includes: when the subpage corresponding to the first sub-route is accessed through the second tab, obtaining the attribute value of the target attribute in the browser's Window object, wherein the first sub-route is any sub-route in the set of route objects; if the attribute value contains a target identifier, determining that the state of the subpage corresponding to the first sub-route is an abnormal state; if the attribute value does not contain the target identifier, determining that the state of the subpage corresponding to the first sub-route is a normal state.
2. The method for determining page state according to claim 1, characterized in that, Obtain the set of route objects for the target webpage, including: Intercept multiple request messages and determine a routing interface from multiple interfaces of the target webpage based on the multiple request messages, wherein each of the multiple request messages is used to access one of the multiple interfaces; Obtain the return information of the routing interface returned by the server of the target webpage, and obtain the set of routing objects of the target webpage from the return information.
3. The method for determining page state according to claim 2, characterized in that, Before intercepting multiple request messages, the method further includes: Log in to the target webpage using the target account, and store the obtained text data corresponding to the target account in the browser, wherein the server of the target webpage identifies the target account based on the text data; The browser is controlled to send the multiple request messages to the server of the target webpage.
4. The method for determining page state according to claim 1, characterized in that, After determining the state of the sub-page corresponding to each sub-route, the method further includes: If the state of the subpage corresponding to the second sub-route is abnormal, determine the component name of the component in the target webpage that corresponds to the second sub-route, wherein the second sub-route is a sub-route in the set of route objects; The system stores the correspondence between the second sub-route and the component name, as well as the target image, wherein the target image is an image of the second tab page captured when the sub-page corresponding to the second sub-route is accessed on the second tab page.
5. The method for determining page state according to claim 1, characterized in that, Accessing the sub-page corresponding to each sub-route in the set of route objects on the second tab includes: Determine the initial number of tabs that the browser is allowed to open simultaneously; Create a second number of second tabs, and access the sub-pages corresponding to the second number of sub-routes in the set of routing objects each time on the second number of second tabs, until all sub-pages corresponding to each sub-route in the set of routing objects have been accessed, wherein the first number is equal to the second number plus one.
6. A device for determining page state, characterized in that, include: The first acquisition module is used to obtain the Uniform Resource Locator (URL) of the target webpage; The second acquisition module is used to access the target webpage through the URL on the first tab and acquire a set of routing objects of the target webpage, wherein the set of routing objects includes multiple sub-routes, and each sub-route in the multiple sub-routes is used to switch from the main page of the target webpage to the sub-page corresponding to each sub-route; The determination module is used to access the sub-page corresponding to each sub-route in the set of route objects on the second tab, and determine the status of the sub-page corresponding to each sub-route; The determining module includes a first access unit, used to concatenate each sub-route with the URL to obtain a page link corresponding to each sub-route; and access the sub-page corresponding to each sub-route through the page link corresponding to each sub-route on the second tab. The determining module includes a determining unit, configured to, when accessing a subpage corresponding to a first sub-route via the second tab, obtain the attribute value of a target attribute in the browser's Window object, wherein the first sub-route is any sub-route in the set of route objects; if the attribute value contains a target identifier, determine that the state of the subpage corresponding to the first sub-route is an abnormal state; if the attribute value does not contain the target identifier, determine that the state of the subpage corresponding to the first sub-route is a normal state.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method of any one of claims 1 to 5.
8. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 5 through the computer program.
Citation Information
Patent Citations
Detection device and method for website redirection
CN104679747A
Webpage analysis method, device and equipment and storage medium
CN110928767A