Resource access method and device, resource storage method and device, equipment and storage medium
By locally storing the specified page resources of the target website obtained from the server in advance and using the crawler service to crawl the resource package on the mobile terminal, the problem of long download time and large space occupation of the full resource package is solved, and efficient storage and quick access of resources are achieved. , which improves the user experience.
Patent Information
- Application Number
- CN202310226454.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-09
- Publication Date
- 2024-09-10
AI Technical Summary
In the existing technology, it takes a long time for the mobile terminal to download the full resource package and takes up a large storage space, and the resource usage rate is low, which affects the user experience.
By locally storing the page resources of the specified page of the target website obtained from the server in advance on the mobile terminal, the crawler service is used to crawl and package the resource package, and when needed, it is obtained from the server, decompressed and stored locally, thereby reducing the download of the full resource package. and storage.
It saves resource download time and network traffic, improves the utilization of local storage resources, and improves user experience.
Smart Images

Figure CN118626700A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of Internet technology, and in particular to a resource access method, a resource storage method, an apparatus, a device, and a storage medium. Background Art
[0002] With the rapid development of mobile Internet technology, more and more applications (such as browsers, readers, etc.) are installed on mobile terminals such as smart phones. These applications usually need to load pages frequently during use, and page loading takes a certain amount of time, which affects the timeliness of the page content displayed to users. In order to increase the speed at which users access page resources, the relevant technology usually packages the full resources of the application and provides them to the client, so that the client can download the full resource package to the local mobile terminal, and then achieve resource acquisition from the local full resource package of the mobile terminal when the user accesses the page resources of the application in the future.
[0003] However, in the above solution, since the full resource package is usually relatively large, the client will spend a long time and use more network traffic when downloading the full resource package, and it will take up more storage space on the mobile terminal. In addition, the actual utilization rate of the resources in the full resource package is low, which seriously affects the experience of mobile terminal users. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the embodiments of the present disclosure provide a resource access method, a resource storage method, an apparatus, a device and a storage medium to solve the defects in the related art.
[0005] According to a first aspect of an embodiment of the present disclosure, a resource access method is provided, which is applied to a mobile terminal, and the method includes:
[0006] In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource;
[0007] Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service;
[0008] In response to finding the target resource in the page resource, acquiring the target resource from the page resource;
[0009] The target resource is sent to the client for access by the client.
[0010] In some embodiments, the method further includes pre-storing the page resource of the designated page locally in the mobile terminal based on the following method:
[0011] In response to detecting that the client is started, obtaining the resource package from the server;
[0012] The page resources of the designated page are obtained by decompressing the resource package, and the page resources are stored locally in the mobile terminal.
[0013] In some embodiments, the method further comprises:
[0014] Obtaining page resource information of the page resource from the server;
[0015] In response to determining that the mobile terminal currently meets a resource package acquisition condition based on the page resource information, the operation of acquiring the resource package from the server is performed.
[0016] In some embodiments, the page resource information includes a page identifier of the specified page;
[0017] The mobile terminal currently meets the resource package acquisition conditions, including:
[0018] The page resource is not found locally on the mobile terminal based on the page identifier.
[0019] In some embodiments, the page resource information includes a page identifier of the specified page and a resource version of the page resource;
[0020] The mobile terminal currently meets the resource package acquisition conditions, including:
[0021] The page resource is found locally on the mobile terminal based on the page identifier, and it is determined based on the resource version that the resource version of the page resource stored locally on the mobile terminal is different from the resource version of the page resource stored on the server.
[0022] In some embodiments, the method further comprises:
[0023] In response to not finding the target resource in the page resources, sending a resource acquisition request for acquiring the target resource to a server, and receiving the target resource returned by the server based on the resource acquisition request.
[0024] According to a second aspect of an embodiment of the present disclosure, a resource storage method is provided, which is applied to a server, and the method includes:
[0025] In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service;
[0026] In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
[0027] In some embodiments, the method includes pre-caching the resource bundle locally on the server based on the following manner:
[0028] In response to detecting that a resource crawling condition is currently met, starting the pre-configured crawler service;
[0029] crawling page resources of the designated page from the designated page in the target website based on the crawler service;
[0030] The resource package uploaded by the crawler service is received and cached locally on the server, wherein the resource package is obtained by the crawler service packaging the page resources.
[0031] In some embodiments, the resource crawling condition currently being satisfied includes at least one of the following:
[0032] Currently receiving resource crawling instructions;
[0033] Currently, notification information is received indicating that a page resource of a specified page in a target website has been updated.
[0034] In some embodiments, the method further comprises pre-configuring the crawler service based on:
[0035] Install the crawler application corresponding to the crawler service in the current project based on the set installation tool;
[0036] In response to completing the installation of the crawler application, configuring cache related information of the crawler service in the configuration file of the current project, the cache related information including at least one of a page link of a target crawling page, user agent information of a Webview component in a client, and server interface information;
[0037] Create a new application cache file in the current project, where the application cache file is used to write related scripts;
[0038] The name of the crawler application and the libraries and software development kits related to the crawler application are introduced into the relevant script.
[0039] In some embodiments, the starting the pre-configured crawler service includes:
[0040] Launching a headless browser based on the crawler application;
[0041] In response to the headless browser being started, creating a new tab in the headless browser;
[0042] Based on the tab page, the headless browser is adjusted from a default computer mode to a mobile mode.
[0043] In some embodiments, crawling the page resources of the designated page from the designated page in the target website based on the crawler service includes:
[0044] In the newly created tab, opening the target crawling page based on the page link;
[0045] In response to the target crawling page being opened, controlling the target crawling page to scroll up and down to load lazy loading resources, and monitoring response information of each request in the target crawling page;
[0046] In response to monitoring the response information, acquiring the page resource from the response information based on a crawled resource type, wherein the crawled resource type is determined based on a mode of the headless browser;
[0047] In response to acquiring the page resource, the page resource is stored in a local designated directory of the server, and storage file information of the page resource is recorded, wherein the storage file information includes at least one of a file link, a file name, a content type, and a character encoding.
[0048] According to a third aspect of an embodiment of the present disclosure, a resource access device is provided, which is applied to a mobile terminal, and the device includes:
[0049] A resource information determination module, configured to determine target resource information of a target resource in response to an access request for accessing a target resource sent by a client being intercepted;
[0050] A target resource search module, used to search for the target resource in the local storage resources of the mobile terminal based on the target resource information, wherein the local storage resources include page resources of a specified page in the target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from a server, and the resource package is obtained by the server crawling the page resources from the specified page in the target website using a crawler service;
[0051] A target resource acquisition module, configured to acquire the target resource from the page resource in response to finding the target resource in the page resource;
[0052] The target resource sending module is used to send the target resource to the client for access by the client.
[0053] In some embodiments, the device further comprises a page resource storage module;
[0054] The page resource storage module includes:
[0055] A resource package acquisition unit, configured to acquire the resource package from the server in response to detecting that the client is started;
[0056] The page resource storage unit is used to obtain the page resource of the designated page by decompressing the resource package, and store the page resource locally in the mobile terminal.
[0057] In some embodiments, the apparatus further comprises:
[0058] A resource information acquisition unit, used to acquire page resource information of the page resource from the server;
[0059] The resource package acquisition unit is further configured to execute the operation of acquiring the resource package from the server in response to determining that the mobile terminal currently meets the resource package acquisition condition based on the page resource information.
[0060] In some embodiments, the page resource information includes a page identifier of the specified page;
[0061] The mobile terminal currently meets the resource package acquisition conditions, including:
[0062] The page resource is not found locally on the mobile terminal based on the page identifier.
[0063] In some embodiments, the page resource information includes a page identifier of the specified page and a resource version of the page resource;
[0064] The mobile terminal currently meets the resource package acquisition conditions, including:
[0065] The page resource is found locally on the mobile terminal based on the page identifier, and it is determined based on the resource version that the resource version of the page resource stored locally on the mobile terminal is different from the resource version of the page resource stored on the server.
[0066] In some embodiments, the apparatus further comprises:
[0067] The target resource receiving module is used to send a resource acquisition request for acquiring the target resource to a server in response to the target resource not being found in the page resources, and receive the target resource returned by the server based on the resource acquisition request.
[0068] According to a fourth aspect of an embodiment of the present disclosure, there is provided a resource storage device, which is applied to a server, and the device includes:
[0069] A resource package acquisition module, configured to, in response to receiving a request message for acquiring a resource package sent by a mobile terminal, acquire the resource package cached in advance from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service;
[0070] The resource package sending module is used for sending the resource package to the mobile terminal in response to obtaining the resource package, so that the mobile terminal can obtain the page resource based on the resource package and store it locally in the mobile terminal.
[0071] In some embodiments, the apparatus includes a resource bundle caching module;
[0072] The resource package cache module includes:
[0073] A crawler service starting unit, configured to start the pre-configured crawler service in response to detecting that a resource crawling condition is currently met;
[0074] A page resource crawling unit, configured to crawl page resources of the designated page from the designated page in the target website based on the crawler service;
[0075] The resource package cache unit is used to receive the resource package uploaded by the crawler service and cache it locally on the server. The resource package is obtained by the crawler service packaging the page resources.
[0076] In some embodiments, the resource crawling condition currently being satisfied includes at least one of the following:
[0077] Currently receiving resource crawling instructions;
[0078] Currently, notification information is received indicating that a page resource of a specified page in a target website has been updated.
[0079] In some embodiments, the resource package cache module further includes a crawler service configuration unit;
[0080] The crawler service configuration unit is used to:
[0081] Install the crawler application corresponding to the crawler service in the current project based on the set installation tool;
[0082] In response to completing the installation of the crawler application, configuring cache related information of the crawler service in the configuration file of the current project, the cache related information including at least one of a page link of a target crawling page, user agent information of a Webview component in a client, and server interface information;
[0083] Create a new application cache file in the current project, where the application cache file is used to write related scripts;
[0084] The name of the crawler application and the libraries and software development kits related to the crawler application are introduced into the relevant script.
[0085] In some embodiments, the crawler service startup unit is further used to:
[0086] Launching a headless browser based on the crawler application;
[0087] In response to the headless browser being started, creating a new tab in the headless browser;
[0088] Based on the tab page, the headless browser is adjusted from a default computer mode to a mobile mode.
[0089] In some embodiments, the page resource crawling unit is further used to:
[0090] In the newly created tab, opening the target crawling page based on the page link;
[0091] In response to the target crawling page being opened, controlling the target crawling page to scroll up and down to load lazy loading resources, and monitoring response information of each request in the target crawling page;
[0092] In response to monitoring the response information, acquiring the page resource from the response information based on a crawled resource type, wherein the crawled resource type is determined based on a mode of the headless browser;
[0093] In response to acquiring the page resource, the page resource is stored in a local designated directory of the server, and storage file information of the page resource is recorded, wherein the storage file information includes at least one of a file link, a file name, a content type, and a character encoding.
[0094] According to a fifth aspect of an embodiment of the present disclosure, there is provided a mobile terminal, including:
[0095] a processor and a memory for storing a computer program;
[0096] Wherein, the processor is configured to implement, when executing the computer program:
[0097] In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource;
[0098] Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service;
[0099] In response to finding the target resource in the page resource, acquiring the target resource from the page resource;
[0100] The target resource is sent to the client for access by the client.
[0101] According to a sixth aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor of a mobile terminal, the following is implemented:
[0102] In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource;
[0103] Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service;
[0104] In response to finding the target resource in the page resource, acquiring the target resource from the page resource;
[0105] The target resource is sent to the client for access by the client.
[0106] According to a seventh aspect of an embodiment of the present disclosure, a server is provided, including:
[0107] a processor and a memory for storing a computer program;
[0108] Wherein, the processor is configured to implement, when executing the computer program:
[0109] In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service;
[0110] In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
[0111] According to an eighth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor of a server, the following is implemented:
[0112] In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service;
[0113] In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
[0114] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0115] The present disclosure determines the target resource information of the target resource in response to an access request intercepted and sent by a client for requesting access to the target resource, and searches for the target resource in the local storage resources of the mobile terminal based on the target resource information. The local storage resources include page resources of a specified page in a target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from a server, and the resource package is obtained by the server crawling page resources from the specified page in the target website using a crawler service. Then, in response to finding the target resource in the page resources, the target resource is obtained from the page resources, and then the target resource is sent to the client for access by the client. Since the local storage of the mobile terminal is the page resource of the specified page in the target website obtained from the server, rather than the full resource package of the target website, it can save resource download time and network traffic, as well as resource storage space, and can also improve the speed of searching for the target resource locally in the mobile terminal, improve the utilization rate of the local storage resources of the mobile terminal, and thus effectively improve the user experience.。
[0116] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0117] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0118] Figure 1 is a flow chart of a resource access method according to an exemplary embodiment of the present disclosure;
[0119] Figure 2 is a flowchart showing how to store the page resource of the designated page locally in the mobile terminal according to an exemplary embodiment of the present disclosure;
[0120] Figure 3 is a flowchart showing how to store the page resource of the designated page locally in the mobile terminal according to another exemplary embodiment of the present disclosure;
[0121] Figure 4 is a flow chart of a resource storage method according to an exemplary embodiment of the present disclosure;
[0122] Figure 5 is a flowchart showing how to cache the resource package locally on the server according to an exemplary embodiment of the present disclosure;
[0123] Figure 6 is a flowchart showing how to configure the crawler service according to an exemplary embodiment of the present disclosure;
[0124] Figure 7 is a flowchart showing how to start the pre-configured crawler service according to an exemplary embodiment of the present disclosure;
[0125] Figure 8 is a flowchart showing how to crawl the page resources of the designated page from the designated page in the target website based on the crawler service according to an exemplary embodiment of the present disclosure;
[0126] Fig. 9 is a block diagram of a resource access device according to an exemplary embodiment of the present disclosure;
[0127] Fig.10 is a block diagram of another resource access device according to an exemplary embodiment of the present disclosure;
[0128] Fig.11is a block diagram of a resource storage device according to an exemplary embodiment of the present disclosure;
[0129] Fig.12 is a block diagram of another resource storage device according to an exemplary embodiment of the present disclosure;
[0130] Fig.13 It is a block diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0131] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0132] Figure 1 It is a flow chart of a resource access method according to an exemplary embodiment; the method of this embodiment can be applied to mobile terminals (such as smart phones, tablet computers, e-readers, smart watches, etc.).
[0133] like Figure 1 As shown, the method includes the following steps S101-S103:
[0134] In step S101, in response to intercepting an access request sent by a client for accessing a target resource, target resource information of the target resource is determined.
[0135] In this embodiment, when the user of the mobile terminal wants to access the target resource, the client can send an access request to the server for accessing the target resource based on the Webview component of the client. Then, the mobile device can intercept the access request and determine the target resource information of the target resource.
[0136] In some embodiments, the mobile terminal can unconditionally intercept all requests issued by the client's Webview component, or can first determine whether the request is a resource access request for accessing resources, and then intercept the access request when it is determined that the request is a resource access request for accessing resources.
[0137] Exemplarily, the access request may be an HTTP request, and the mobile terminal may determine the target resource information of the target resource, such as identification information of the target resource, based on the information carried in the access request (such as domain name information, etc.). This embodiment does not limit this.
[0138] In step S102, based on the target resource information, the target resource is searched in the local storage resources of the mobile terminal.
[0139] In this embodiment, after the target resource information of the target resource is determined, the target resource may be searched in the local storage resources of the mobile terminal based on the target resource information.
[0140] The local storage resources of the mobile terminal include page resources of a specified page in the target website pre-stored in the local storage of the mobile terminal, and the page resources are obtained by a resource package pre-acquired from a server, and the resource package is obtained by crawling the page resources from the specified page in the target website by the server using a crawler service. It is worth noting that the target website referred to in the present disclosure may include an H5 single-page application, and the specified page may be a specified page in the H5 single-page application.
[0141] That is to say, the server can use the crawler service to crawl page resources from the specified page in the target website in advance, and package the crawled page resources to obtain a resource package; then, the mobile terminal can obtain the resource package from the server at a preset time, and then decompress the resource package to obtain the page resources, and then store the page resources in the local storage resources of the mobile terminal. In this way, when the mobile terminal subsequently intercepts the access request sent by the client to request access to the target resource, the target resource information of the target resource can be determined, so as to search for the target resource in the local storage resources of the mobile terminal based on the target resource information.
[0142] It is worth noting that the preset timing for the mobile terminal to obtain the resource package from the server can be set based on actual application scenario requirements or related business experience requirements, such as when the client is started, etc. This embodiment does not limit this.
[0143] In step S103, in response to finding the target resource in the page resource, the target resource is acquired from the page resource.
[0144] In this embodiment, after the mobile terminal performs the above operation of searching for the target resource in the local storage resources of the mobile terminal, if the target resource is found in the page resource, the target resource can be directly obtained from the page resource.
[0145] It can be understood that since the local pre-stored content of the mobile terminal is the page resources of the specified page in the target website obtained from the server, rather than the full resource package of the target website, the resource download time of the mobile terminal can be shortened, the network traffic and storage space required for resource transmission can be saved, and the search scope of the target resources can be narrowed, thereby greatly improving the speed of searching for the target resources from the local of the mobile terminal; on the other hand, since the above-mentioned specified page can be a web page with a high user access rate in the target website specified based on historical data or business experience, the utilization rate of the local storage resources of the mobile terminal can be improved.
[0146] In other embodiments, if the target resource is not found in the page resources, a resource acquisition request for acquiring the target resource may be sent to the server, and the target resource returned by the server based on the resource acquisition request may be received. That is, when the target resource is not found in the page resources, a resource acquisition request for acquiring the target resource may continue to be sent to the server to request the server to send the target resource.
[0147] In step S104, the target resource is sent to the client for access by the client.
[0148] In this embodiment, after the target resource is obtained from the page resource, the target resource may be sent to the client for access by the client.
[0149] If the target resource is found in the page resource, the target resource can be directly obtained from the page resource without requesting the target resource from the server based on the access request. This can improve the access rate of the target resource and effectively improve the user experience.
[0150] As can be seen from the above description, the method of this embodiment determines the target resource information of the target resource in response to an access request for accessing the target resource sent by the client, and searches for the target resource in the local storage resources of the mobile terminal based on the target resource information. The local storage resources include page resources of a specified page in the target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from the server, and the resource package is obtained by the server using a crawler service to crawl page resources from the specified page in the target website. Then, in response to finding the target resource in the page resource, the target resource is obtained from the page resource, and then the target resource is sent to the client for access by the client. Since the local storage of the mobile terminal is the page resource of the specified page in the target website obtained from the server, rather than the full resource package of the target website, it can save resource download time and network traffic, as well as save resource storage space, and can also improve the speed of searching for target resources from the local of the mobile terminal, improve the utilization rate of the local storage resources of the mobile terminal, and thus effectively improve the user experience.
[0151] Figure 2 This is a flowchart showing how to store the page resources of the specified page locally in the mobile terminal according to an exemplary embodiment of the present disclosure; this embodiment is based on the above embodiment and takes how to store the page resources of the specified page locally in the mobile terminal as an example for exemplary description. Figure 2 As shown, the resource access method of this embodiment may further include storing the page resource of the designated page locally in the mobile terminal based on the following steps S201-S203:
[0152] In step S201, in response to detecting that the client is started, the resource package is obtained from the server.
[0153] In this embodiment, when the mobile terminal detects that the client is started, the resource package can be obtained from the server.
[0154] It is understandable that every time a user wants to use a client to access resources, the client will be started first. Therefore, setting the preset timing for the mobile terminal to obtain resource packages from the server to when the client is started can not only improve the effectiveness of the obtained resource packages, but also increase the probability of the obtained resource packages being used, thereby avoiding waste of network resources.
[0155] In step S202, the resource package is decompressed to obtain the page resource of the designated page.
[0156] In this embodiment, after the mobile terminal obtains the resource package from the server, the resource package may be decompressed to obtain the page resource of the designated page.
[0157] For example, the resource package may be a ZIP or other type of resource package. After the resource package is obtained from the server, the resource package may be decompressed based on a decompression tool of the corresponding resource package type to obtain the files in the resource package, namely, the page resources of the specified page.
[0158] In step S203, the page resource is stored locally in the mobile terminal.
[0159] In this embodiment, after the page resource of the designated page is obtained, the page resource may be stored locally in the mobile terminal.
[0160] For example, when the mobile terminal stores the above-mentioned page resources locally, it can record the storage file information of the page resources, such as the file link, file name, content type (mimeType) and at least one of the character encoding. Then, when the mobile terminal subsequently intercepts the access request sent by the client for requesting access to the target resource and determines the target resource information of the target resource, it can query the corresponding storage file information based on the target resource information (for example, based on a pre-constructed correspondence table, query the storage file information corresponding to the target resource information), and then obtain the above-mentioned page resources from the local corresponding location of the mobile terminal according to the storage file information.
[0161] As can be seen from the above description, this embodiment obtains the resource package from the server in response to detecting that the client is started, decompresses the resource package, obtains the page resource of the specified page, and then stores the page resource locally on the mobile terminal. It can be achieved that the resource package is obtained from the server based on a preset timing, and the page resource decompressed from the resource package is stored locally on the mobile terminal. It can be achieved that when the mobile terminal intercepts an access request sent by the client to request access to the target resource, the target resource information of the target resource is determined, and the target resource is searched for in the local storage resources of the mobile terminal based on the target resource information. Since what is obtained from the server is the page resource of the specified page in the target website, rather than the full resource package of the target website, it can save resource download time and network traffic, as well as save resource storage space, and can also improve the speed of subsequent search for target resources from the local mobile terminal, thereby effectively improving the user experience.
[0162] Figure 3FIG. 1 is a flowchart showing how to store the page resources of the specified page locally in the mobile terminal according to another exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment takes how to store the page resources of the specified page locally in the mobile terminal as an example for exemplary description. Figure 3 As shown, the resource access method of this embodiment may further include storing the page resource of the designated page locally in the mobile terminal based on the following steps S301-S304:
[0163] In step S301, in response to detecting that the client is started, page resource information of the page resource is obtained from the server.
[0164] In this embodiment, when the mobile terminal detects that the client is started, the page resource information of the page resource can be obtained from the server.
[0165] In some embodiments, the page resource information may include a page identifier of the designated page and / or a resource version of the page resource.
[0166] In step S302, in response to determining that the mobile terminal currently meets a resource package acquisition condition based on the page resource information, the resource package is acquired from a server.
[0167] In this embodiment, after the mobile terminal obtains the page resource information of the page resource from the server, it can determine whether the mobile terminal currently meets the resource package acquisition conditions based on the page resource information, and then when it is determined that the mobile terminal currently meets the resource package acquisition conditions, the resource package is obtained from the server.
[0168] For example, if the page resource information includes the page identifier of the specified page, then the mobile terminal currently meets the resource package acquisition condition, which may include: the page resource is not found locally on the mobile terminal based on the page identifier. In other words, when it is detected that the page resource corresponding to the page identifier does not exist locally on the mobile terminal, it can be determined that the mobile terminal currently meets the resource package acquisition condition.
[0169] For another example, if the page resource information includes the page identifier of the specified page and the resource version of the page resource of the specified page, then the mobile terminal currently meets the resource package acquisition condition, which may include: finding the page resource locally on the mobile terminal based on the page identifier, and determining based on the resource version that the resource version of the page resource locally stored on the mobile terminal is different from the resource version of the page resource stored on the server. That is, when it is detected that the page resource corresponding to the page identifier exists locally on the mobile terminal, the resource version of the page resource (named as the first resource version for easy distinction) can be further detected and compared with the resource version of the page resource stored on the server (named as the second resource version for easy distinction). If the first resource version is inconsistent with the second resource version, it can be regarded as the page resource stored on the server has been updated, and then it can be determined that the mobile terminal currently meets the resource package acquisition condition; on the contrary, if the first resource version is consistent with the second resource version, it can be regarded as the page resource stored on the server has not been updated, and then it can be determined that the mobile terminal currently does not meet the resource package acquisition condition.
[0170] It is understandable that each time a user wants to use a client to access resources, the client is started first. Therefore, when the client is detected to be started, the page resource information of the page resource is first obtained from the server, so that it can be realized that based on the page resource information, it is determined whether the above-mentioned page resources stored on the server have been updated, and then it is determined whether the page resources stored locally on the mobile terminal need to be updated (that is, when the page resources stored on the server are updated, it is determined that the resources stored locally on the mobile terminal need to be updated). Therefore, when it is determined that an update is required, the resource package is obtained from the server, which can effectively avoid the waste of network resources and increase the probability of the obtained resource package being used.
[0171] In step S303, the resource package is decompressed to obtain the page resource of the designated page.
[0172] In step S304, the page resource is stored locally in the mobile terminal.
[0173] The explanation and description of steps S303-S304 can be found in the above Figure 2 Steps S202 - S203 in the illustrated embodiment are not described in detail here.
[0174] As can be seen from the above description, this embodiment obtains the page resource information of the page resource from the server in response to detecting that the client is started, and obtains the resource package from the server in response to determining that the mobile terminal currently meets the resource package acquisition conditions based on the page resource information. This can achieve more accurate determination of the timing for the mobile terminal to obtain the resource package from the server, improve the timeliness and effectiveness of resource package acquisition, and facilitate the subsequent local storage of page resources in the mobile terminal based on the resource package.
[0175] Figure 4 It is a flowchart of a resource storage method according to an exemplary embodiment of the present disclosure; the method of this embodiment can be applied to server ends such as local servers and cloud servers, and the server end can be deployed in a device cluster consisting of one electronic device or multiple electronic devices.
[0176] like Figure 4 As shown, the method includes the following steps S401-S402:
[0177] In step S401, in response to receiving request information for obtaining a resource package sent by a mobile terminal, the resource package pre-cached is obtained from the local of the server.
[0178] In this embodiment, when the server receives the request information for obtaining the resource package sent by the mobile terminal, the resource package pre-cached can be obtained from the local of the server.
[0179] The resource package includes page resources of a designated page in the target website, and the resource package is obtained by crawling the page resources from the designated page in the target website in advance using a crawler service.
[0180] That is to say, the server can pre-use the crawler service to crawl page resources from the specified page in the target website, and package the crawled page resources to obtain a resource package, and then cache the resource package locally on the server. On this basis, when the mobile terminal reaches a preset time, it can send a request message for obtaining the resource package to the server. Then, the server can obtain the pre-cached resource package from the local server in response to receiving the request message.
[0181] In some embodiments, when the server caches the above-mentioned resource package locally, it can record the storage file information of the resource package, such as the file link, file name, content type (mimeType) and at least one of the character encoding. Then, when the server receives the request information sent by the mobile terminal, it can obtain the above-mentioned resource package from the local corresponding location of the server based on the storage file information.
[0182] In step S402, in response to obtaining the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
[0183] In this embodiment, after the server obtains the resource package, it can send the resource package to the mobile terminal, so that the mobile terminal can obtain the page resource based on the resource package and store it locally in the mobile terminal.
[0184] For example, after the mobile terminal obtains the resource package from the server, it can decompress the resource package to obtain the page resource, and then store the page resource in the local storage resource of the mobile terminal. On this basis, when the mobile terminal subsequently intercepts an access request sent by the client to request access to the target resource, it can determine the target resource information of the target resource, so as to search for the target resource in the local storage resource of the mobile terminal based on the target resource information.
[0185] Since the server sends the page resources of the specified page in the target website to the mobile terminal instead of the full resource package of the target website, the resource download time of the mobile terminal can be shortened, the network traffic and storage space required for resource transmission can be saved, and the search scope of the target resources can be narrowed, thereby greatly improving the speed of searching for the target resources locally on the mobile terminal; on the other hand, since the above-mentioned specified page can be a web page with a high user access rate in the target website specified based on historical data or business experience, the utilization rate of the local storage resources of the mobile terminal can be improved.
[0186] As can be seen from the above description, the method of this embodiment obtains the pre-cached resource package from the local of the server in response to receiving the request information for obtaining the resource package sent by the mobile terminal, the resource package includes the page resources of the specified page in the target website, and the resource package is obtained by pre-crawling the page resources from the specified page in the target website using the crawler service, and then in response to obtaining the resource package, the resource package is sent to the mobile terminal so that the mobile terminal can obtain the page resources based on the resource package and store them locally in the mobile terminal. Since the server sends the page resources of the specified page in the target website to the mobile terminal instead of the full resource package of the target website, it can save the resource download time and network traffic of the mobile terminal, as well as the resource storage space of the mobile terminal, and can also improve the speed of the mobile terminal's subsequent search for target resources locally, improve the utilization rate of the local storage resources of the mobile terminal, and thus effectively improve the user experience.
[0187] Figure 51 is a flowchart showing how to cache the resource package locally on the server according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment takes how to cache the resource package locally on the server as an example for exemplary description. Figure 5 As shown, the resource storage method of this embodiment may further include caching the resource package locally on the server based on the following steps S501-S503:
[0188] In step S501, in response to detecting that a resource crawling condition is currently met, the pre-configured crawler service is started.
[0189] In this embodiment, the server can detect whether the resource crawling condition is currently met based on a preset frequency, and then start the pre-configured crawler service when it is detected that the resource crawling condition is currently met.
[0190] In some embodiments, the situation in which the server currently satisfies the resource crawling condition may include at least one of the following (1) and (2):
[0191] (1) Currently receiving a resource crawling instruction. For example, a relevant person may send a resource crawling instruction to the server based on actual needs, and the server may start a pre-configured crawler service in response to receiving the instruction.
[0192] It is worth noting that the type of the above crawler service can be set based on the actual application scenario requirements or related business experience needs, such as being set to a crawler service based on puppeteer technology, etc. This embodiment does not limit this.
[0193] (2) Notification information indicating that a page resource of a specified page in a target website has been updated is currently received. For example, the server may sign an agreement with the target website to agree that when a page resource of a specified page in the target website has been updated, corresponding notification information will be sent to the server, and the server may start a pre-configured crawler service in response to receiving the notification information.
[0194] In this embodiment, the method of pre-configuring the above crawler service and starting the above crawler service can refer to the explanations and instructions in the relevant technology, and this embodiment does not limit this.
[0195] In some other embodiments, the method of pre-configuring the above crawler service can also be referred to as follows Figure 6 The method of starting the crawler service can also refer to the following Figure 7 The illustrated embodiment will not be described in detail here.
[0196] In step S502, page resources of the designated page are crawled from the designated page in the target website based on the crawler service.
[0197] In this embodiment, after the pre-configured crawler service is started, the page resources of the designated page can be crawled from the designated page in the target website based on the crawler service.
[0198] In this embodiment, the manner in which the crawler service crawls the page resources of the designated page from the designated page in the target website can be referred to the explanations and descriptions in the relevant technologies, and this embodiment does not limit this.
[0199] In some other embodiments, the method for the crawler service to crawl page resources can also be referred to as follows: Figure 8 The illustrated embodiment will not be described in detail here.
[0200] In step S503, the resource package uploaded by the crawler service is received and cached locally on the server.
[0201] In this embodiment, after crawling the page resources of the specified page from the specified page in the target website based on the crawler service, the crawler service can package the crawled page resources, and then upload the obtained resource package to the server, and then the server can cache the received resource package locally on the server for subsequent use.
[0202] From the above description, it can be seen that this embodiment can realize crawling the page resources of the specified page based on the crawler service, and receive the resource package containing the page resources sent by the crawler service, and then cache the resource package locally on the server for subsequent use. Since the crawler service is started to crawl page resources when it is detected that the resource crawling conditions are currently met, the timing of resource crawling can be grasped by reasonably setting the resource crawling conditions, thereby ensuring the timeliness of the crawler service crawling page resources, and then improving the effectiveness of the page resources stored locally on the server.
[0203] Figure 6 FIG. 1 is a flowchart showing how to configure the crawler service according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment takes how to configure the crawler service as an example for exemplary description. Figure 6 As shown, the resource storage method of this embodiment may further include configuring the crawler service based on the following steps S601-S604:
[0204] In step S601, a crawler application corresponding to the crawler service is installed in the current project based on a setting installation tool.
[0205] In this embodiment, when configuring the crawler service, a crawler application corresponding to the crawler service may be installed in the current project based on a setting installation tool.
[0206] The above-mentioned current project may include a currently created project for crawling page resources of a specified page in a target website.
[0207] It is worth noting that the above-mentioned setting installation tool can be set based on the actual application scenario requirements or related business experience needs, such as setting it to npm (Node.js package management tool) or yarn (JavaScript package management tool), etc., and this embodiment does not limit this.
[0208] In step S602, in response to completing the installation of the crawler application, cache related information of the crawler service is configured in the configuration file of the current project.
[0209] In this embodiment, after the installation of the crawler application is completed, cache-related information of the crawler service may be configured in the configuration file of the current project.
[0210] For example, the cache-related information may include at least one of the page link of the target crawling page (ie, the page to be crawled), the user agent information (userAgent) of the Webview component in the client, and the server interface information.
[0211] In step S603, a new application cache file is created in the current project.
[0212] In this embodiment, after configuring the cache related information of the crawler service, a new application cache file may be created in the current project for use in writing related scripts.
[0213] The format of the application cache file may be set based on actual business needs, such as being set as a file in ".js" format, etc. This embodiment does not limit this.
[0214] In step S604, the name of the crawler application and the library and software development kit related to the crawler application are introduced into the relevant script.
[0215] In this embodiment, after a new application cache file (such as appCache.js file, etc.) for writing related scripts is created in the current project, the name of the crawler application and the library and software development kit SDK related to the crawler application can be introduced into the script. Exemplarily, the crawler application can be a puppeteer crawler program.
[0216] From the above description, it can be seen that this embodiment installs the crawler application corresponding to the crawler service in the current project based on the setting installation tool, and in response to completing the installation of the crawler application, configures the cache-related information of the crawler service in the configuration file of the current project, and creates a new application cache file in the current project. The application cache file is used to write related scripts, and then introduces the name of the crawler application and the libraries and software development kits related to the crawler application into the related scripts, so as to configure the crawler service, thereby enabling the subsequent crawling of page resources of the specified page by the crawler service based on the configuration, and laying the foundation for the subsequent local storage of resource packages containing the page resources on the server side.
[0217] Figure 7 It is a flowchart showing how to start the pre-configured crawler service according to an exemplary embodiment of the present disclosure; based on the above embodiment, this embodiment uses how to start the pre-configured crawler service as an example to exemplify.
[0218] like Figure 7 As shown, starting the pre-configured crawler service in the above step S501 may include the following steps S701-S703:
[0219] In step S701, a headless browser is started based on the crawler application.
[0220] In this embodiment, when the crawler service is started, a headless browser can be started based on the crawler application.
[0221] The headless browser is a browser without a graphical user interface (GUI). In this embodiment, the crawler service bypasses the anti-crawler strategy by using a headless browser to disguise as a normal user.
[0222] In step S702, in response to the completion of starting the headless browser, a new tab is created in the headless browser.
[0223] In this embodiment, after the headless browser is started based on the crawler application, a new tab can be created in the headless browser.
[0224] Among them, the above-mentioned new tab page can be used to set the mode of the headless browser, and can be used to open the page that needs to be crawled (ie, the target crawling page).
[0225] In step S703, the headless browser is adjusted from a default computer mode to a mobile mode based on the tab.
[0226] In this embodiment, after a new tab is created in the headless browser, the headless browser can be adjusted from a default computer mode to a mobile mode based on the tab.
[0227] It is worth noting that by adjusting the headless browser from the default computer mode to the mobile mode (such as mobile phone mode, etc.), it is possible to crawl the page resources required by the mobile terminal device in the mobile mode. In other words, when it is determined that the browser mode is the mobile mode, the specific type of page resources that the crawler service needs to crawl can be further determined, such as one or more of the static resources of the specified page in the H5 single-page application, the resources dynamically issued by the API (Application Program Interface), and the resources connected to the CDN (Content Delivery Network). In this way, it is possible to avoid the crawler service crawling useless resources corresponding to the computer mode.
[0228] From the above description, it can be seen that this embodiment starts a headless browser based on the crawler application, and in response to the completion of the startup of the headless browser, creates a new tab in the headless browser, and then adjusts the headless browser from the default computer mode to the mobile mode based on the tab, thereby starting a pre-configured crawler service, and then crawling the page resources of the specified page based on the crawler service, which can lay the foundation for the subsequent local storage of the resource package containing the page resources on the server.
[0229] Figure 8 It is a flowchart showing how to crawl the page resources of the specified page from the specified page in the target website based on the crawler service according to an exemplary embodiment of the present disclosure; this embodiment, based on the above embodiment, uses the example of how to crawl the page resources of the specified page from the specified page in the target website based on the crawler service to exemplify.
[0230] like Figure 8 As shown, crawling the page resources of the designated page from the designated page in the target website based on the crawler service in the above step S502 may include the following steps S801-S804:
[0231] In step S801, in the new tab, the target crawling page is opened based on the page link.
[0232] In this embodiment, when the page resources of the specified page are crawled from the specified page in the target website based on the crawler service, the target crawling page can be opened in a new tab created in the process of starting the crawler service (hereinafter referred to as a new tab) based on the page link of the target crawling page determined when configuring the crawler service.
[0233] In step S802, in response to the target crawling page being opened, the target crawling page is controlled to scroll up and down to load lazy loading resources, and response information of each request in the target crawling page is monitored.
[0234] In this embodiment, after the target crawling page is opened, the target crawling page can be controlled to scroll up and down to load lazy load resources, and the response information of each request in the target crawling page can be monitored.
[0235] Among them, each request in the above-mentioned target crawling page can be all or part of the requests that can be triggered by the user on the target crawling page.
[0236] It is understandable that by controlling the target crawling page to scroll up and down, it is possible to load as many lazy loading resources as possible to facilitate subsequent crawling.
[0237] In step S803, in response to monitoring the response information, the page resource is obtained from the response information based on the crawled resource type.
[0238] In this embodiment, when the above response information is monitored, the response information can be filtered based on the currently determined crawled resource type to obtain the page resource therefrom.
[0239] Among them, the above-mentioned crawled resource type can be determined based on the mode of the headless browser.
[0240] In step S804, in response to obtaining the page resource, the page resource is stored in a local designated directory of the server, and the storage file information of the page resource is recorded.
[0241] For example, the page resource can be stored in a local designated directory of the server based on a preset language (such as nodeJS, etc.) with read and write permissions. On this basis, the storage file information of the page resource can be stored in a pre-created target file (such as sourceMap.josn file, etc.). Exemplarily, the storage file information can include at least one of the file link, file name, content type (mimeType) and character encoding (charset) of the target file.
[0242] In one embodiment, when the entire resource loading in the target crawling page is completed, the currently opened tab page can be closed.
[0243] From the above description, it can be seen that this embodiment opens the target crawling page based on the page link in the new tab, and in response to the target crawling page being opened, controls the target crawling page to scroll up and down to load lazy loading resources, and monitors the response information of each request in the target crawling page, and then in response to the response information being monitored, obtains the page resource from the response information based on the crawling resource type, and then in response to obtaining the page resource, stores the page resource in the local designated directory of the server, and records the storage file information of the page resource, so as to realize crawling the page resource of the designated page from the designated page in the target website based on the crawler service, and then realizes the subsequent storage of the resource package containing the page resource locally on the server, thereby laying the foundation for the subsequent mobile terminal to obtain the resource package from the server.
[0244] Taking crawling the page resources of a specified page in the XXXX website (the website address is "https: / / www.XXXX.com") as an example, the following exemplary code implementation content is provided:
[0245]
[0246]
[0247]
[0248] The relevant test results show that the resource access method of the embodiment of the present disclosure can greatly reduce the first screen loading time of the H5 page embedded in the client APP, thereby reducing the first screen loss rate.
[0249] Compared with the full resource caching solution in the related art, the resource storage method of the embodiment of the present disclosure can greatly reduce the size of the cached resource package, thereby shortening the resource package download time, saving the network traffic required for resource transmission, and improving the utilization rate of resources in the resource package.
[0250] Fig. 9 It is a block diagram of a resource access device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to mobile terminals (such as smart phones, tablet computers, e-readers, smart watches, etc.).
[0251] like Fig. 9 As shown, the device includes: a resource information determination module 110, a target resource search module 120, a target resource acquisition module 130 and a target resource sending module 140, wherein:
[0252] The resource information determination module 110 is used to determine the target resource information of the target resource in response to an access request for accessing the target resource sent by the client;
[0253] A target resource search module 120 is used to search for the target resource in the local storage resources of the mobile terminal based on the target resource information, wherein the local storage resources include page resources of a specified page in the target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from a server, and the resource package is obtained by the server crawling the page resources from the specified page in the target website using a crawler service;
[0254] A target resource acquisition module 130, configured to acquire the target resource from the page resource in response to finding the target resource in the page resource;
[0255] The target resource sending module 140 is used to send the target resource to the client for access by the client.
[0256] As can be seen from the above description, the device of this embodiment determines the target resource information of the target resource in response to an access request for accessing the target resource sent by the client, and searches for the target resource in the local storage resources of the mobile terminal based on the target resource information. The local storage resources include page resources of a specified page in the target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from the server, and the resource package is obtained by the server using a crawler service to crawl page resources from the specified page in the target website. Then, in response to finding the target resource in the page resource, the target resource is obtained from the page resource, and then the target resource is sent to the client for access by the client. Since the local storage of the mobile terminal is the page resource of the specified page in the target website obtained from the server, rather than the full resource package of the target website, it can save resource download time and network traffic, as well as save resource storage space, and can also improve the speed of searching for target resources from the local of the mobile terminal, improve the utilization rate of the local storage resources of the mobile terminal, and thus effectively improve the user experience.
[0257] Fig.102 is a block diagram of another resource access device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to a mobile terminal (such as a smart phone, a tablet computer, an e-reader, a smart watch, etc.). Among them, the resource information determination module 210, the target resource search module 220, the target resource acquisition module 230 and the target resource sending module 240 are the same as the aforementioned Fig. 9 The functions of the resource information determination module 110 , the target resource search module 120 , the target resource acquisition module 130 and the target resource sending module 140 in the illustrated embodiment are the same and will not be described in detail herein.
[0258] like Fig.10 As shown, the resource access device of this embodiment further includes a page resource storage module 250;
[0259] The page resource storage module 250 may include:
[0260] A resource package acquisition unit 251 is configured to acquire the resource package from the server in response to detecting that the client is started;
[0261] The page resource storage unit 252 is used to obtain the page resource of the designated page by decompressing the resource package, and store the page resource locally in the mobile terminal.
[0262] In some embodiments, the above apparatus may further include:
[0263] The resource information acquisition unit 253 is used to acquire the page resource information of the page resource from the server;
[0264] Furthermore, the resource package acquisition unit 251 is further configured to execute the operation of acquiring the resource package from the server in response to determining that the mobile terminal currently meets the resource package acquisition condition based on the page resource information.
[0265] In some embodiments, the page resource information may include a page identifier of the specified page;
[0266] Furthermore, the mobile terminal currently meets the resource package acquisition conditions, which may include:
[0267] The page resource is not found locally on the mobile terminal based on the page identifier.
[0268] In some embodiments, the page resource information may include a page identifier of the specified page and a resource version of the page resource;
[0269] Furthermore, the mobile terminal currently meets the resource package acquisition conditions, which may include:
[0270] The page resource is found locally on the mobile terminal based on the page identifier, and it is determined based on the resource version that the resource version of the page resource stored locally on the mobile terminal is different from the resource version of the page resource stored on the server.
[0271] In some embodiments, the above apparatus may further include:
[0272] The target resource receiving module 260 is used to send a resource acquisition request for acquiring the target resource to the server in response to the target resource not being found in the page resources, and receive the target resource returned by the server based on the resource acquisition request.
[0273] Fig.11 It is a block diagram of a resource storage device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to a server such as a local server and a cloud server, and the server can be deployed in a device cluster consisting of one electronic device or multiple electronic devices.
[0274] like Fig.11 As shown, the device includes: a resource package acquisition module 310 and a resource package sending module 320, wherein:
[0275] The resource package acquisition module 310 is used to obtain the resource package cached in advance from the local of the server in response to receiving the request information for obtaining the resource package sent by the mobile terminal, wherein the resource package includes the page resources of the specified page in the target website, and the resource package is obtained by crawling the page resources from the specified page in the target website by using the crawler service in advance;
[0276] The resource package sending module 320 is used for sending the resource package to the mobile terminal in response to obtaining the resource package, so that the mobile terminal can obtain the page resource based on the resource package and store it locally in the mobile terminal.
[0277] As can be seen from the above description, the device of this embodiment obtains the pre-cached resource package from the local of the server in response to receiving the request information for obtaining the resource package sent by the mobile terminal, the resource package includes the page resources of the specified page in the target website, and the resource package is obtained by pre-crawling the page resources from the specified page in the target website using the crawler service, and then in response to obtaining the resource package, the resource package is sent to the mobile terminal so that the mobile terminal can obtain the page resources based on the resource package and store them locally in the mobile terminal. Since the server sends the page resources of the specified page in the target website to the mobile terminal instead of the full resource package of the target website, it can save the resource download time and network traffic of the mobile terminal, as well as the resource storage space of the mobile terminal, and can also improve the speed of the mobile terminal's subsequent search for target resources locally, improve the utilization rate of the local storage resources of the mobile terminal, and thus effectively improve the user experience.
[0278] Fig.12 is a block diagram of another resource storage device according to an exemplary embodiment of the present disclosure; the device of this embodiment can be applied to a server such as a local server and a cloud server, and the server can be deployed in a device cluster consisting of one electronic device or multiple electronic devices. Fig.11 The resource package acquisition module 310 and the resource package sending module 320 in the illustrated embodiment have the same functions, which will not be described in detail herein.
[0279] like Fig.12 As shown, the resource storage device of this embodiment may further include a resource package cache module 430;
[0280] The resource package cache module 430 includes:
[0281] A crawler service starting unit 431 is used to start the pre-configured crawler service in response to detecting that a resource crawling condition is currently met;
[0282] A page resource crawling unit 432, configured to crawl page resources of the designated page from the designated page in the target website based on the crawler service;
[0283] The resource package cache unit 433 is used to receive the resource package uploaded by the crawler service and cache it locally on the server. The resource package is obtained by the crawler service packaging the page resources.
[0284] In some embodiments, the resource crawling condition currently met may include at least one of the following:
[0285] Currently receiving resource crawling instructions;
[0286] Currently, notification information is received indicating that a page resource of a specified page in a target website has been updated.
[0287] In some embodiments, the resource package cache module 430 may further include a crawler service configuration unit 434;
[0288] The crawler service configuration unit 434 can be used to:
[0289] Install the crawler application corresponding to the crawler service in the current project based on the set installation tool;
[0290] In response to completing the installation of the crawler application, configuring cache related information of the crawler service in the configuration file of the current project, the cache related information including at least one of a page link of a target crawling page, user agent information of a Webview component in a client, and server interface information;
[0291] Create a new application cache file in the current project, where the application cache file is used to write related scripts;
[0292] The name of the crawler application and the libraries and software development kits related to the crawler application are introduced into the relevant script.
[0293] In some embodiments, the crawler service startup unit 431 may also be used to:
[0294] Launching a headless browser based on the crawler application;
[0295] In response to the headless browser being started, creating a new tab in the headless browser;
[0296] Based on the tab page, the headless browser is adjusted from a default computer mode to a mobile mode.
[0297] In some embodiments, the page resource crawling unit 432 may also be used to:
[0298] In the newly created tab, opening the target crawling page based on the page link;
[0299] In response to the target crawling page being opened, controlling the target crawling page to scroll up and down to load lazy loading resources, and monitoring response information of each request in the target crawling page;
[0300] In response to monitoring the response information, acquiring the page resource from the response information based on a crawled resource type, wherein the crawled resource type is determined based on a mode of the headless browser;
[0301] In response to acquiring the page resource, the page resource is stored in a local designated directory of the server, and storage file information of the page resource is recorded, wherein the storage file information includes at least one of a file link, a file name, a content type, and a character encoding.
[0302] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0303] Fig.13 900 is a block diagram of an electronic device according to an exemplary embodiment. For example, the device 900 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0304] Reference Fig.13 , device 900 may include one or more of the following components: a processing component 902 , a memory 904 , a power component 906 , a multimedia component 908 , an audio component 910 , an input / output (I / O) interface 912 , a sensor component 914 , and a communication component 916 .
[0305] The processing component 902 generally controls the overall operation of the device 900, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the resource access method or resource storage method described above. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.
[0306] The memory 904 is configured to store various types of data to support operations on the device 900. Examples of such data include instructions for any application or method operating on the device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0307] The power supply component 906 provides power to the various components of the device 900. The power supply component 906 can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 900.
[0308] The multimedia component 908 includes a screen that provides an output interface between the device 900 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0309] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC), and when the device 900 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 904 or sent via the communication component 916. In some embodiments, the audio component 910 also includes a speaker for outputting audio signals.
[0310] I / O interface 912 provides an interface between processing component 902 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0311] The sensor assembly 914 includes one or more sensors for providing various aspects of status assessment for the device 900. For example, the sensor assembly 914 can detect the open / closed state of the device 900, the relative positioning of components, such as the display and keypad of the device 900, and the sensor assembly 914 can also detect the position change of the device 900 or a component of the device 900, the presence or absence of user contact with the device 900, the orientation or acceleration / deceleration of the device 900, and the temperature change of the device 900. The sensor assembly 914 can also include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 914 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 914 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0312] The communication component 916 is configured to facilitate wired or wireless communication between the device 900 and other devices. The device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G or 5G or a combination thereof. In an exemplary embodiment, the communication component 916 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 916 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0313] In an exemplary embodiment, the device 900 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the above-mentioned resource access method or resource storage method.
[0314] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the instructions can be executed by the processor 920 of the device 900 to complete the resource access method or resource storage method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0315] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0316] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A resource access method, It is characterized in that Applied to a mobile terminal, the method comprises: In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource; Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service; In response to finding the target resource in the page resource, acquiring the target resource from the page resource; The target resource is sent to the client for access by the client.
2. The method according to claim 1, It is characterized in that The method further includes pre-storing the page resource of the designated page locally in the mobile terminal in the following manner: In response to detecting that the client is started, obtaining the resource package from the server; Decompressing the resource package to obtain the page resource of the specified page; The page resource is stored locally on the mobile terminal.
3. The method according to claim 2, It is characterized in that The method further comprises: Obtaining page resource information of the page resource from the server; In response to determining that the mobile terminal currently meets a resource package acquisition condition based on the page resource information, the operation of acquiring the resource package from the server is performed.
4. The method according to claim 3, It is characterized in that The page resource information includes a page identifier of the specified page; The mobile terminal currently meets the resource package acquisition conditions, including: The page resource is not found locally on the mobile terminal based on the page identifier.
5. The method according to claim 3, It is characterized in that The page resource information includes the page identifier of the specified page and the resource version of the page resource; The mobile terminal currently meets the resource package acquisition conditions, including: The page resource is found locally on the mobile terminal based on the page identifier, and it is determined based on the resource version that the resource version of the page resource stored locally on the mobile terminal is different from the resource version of the page resource stored on the server.
6. The method according to claim 1, It is characterized in that The method further comprises: In response to not finding the target resource in the page resources, sending a resource acquisition request for acquiring the target resource to a server, and receiving the target resource returned by the server based on the resource acquisition request.
7. A resource storage method, It is characterized in that Applied to the server, the method includes: In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service; In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
8. The method according to claim 7, It is characterized in that The method includes pre-caching the resource bundle locally on the server in the following manner: In response to detecting that a resource crawling condition is currently met, starting the pre-configured crawler service; crawling page resources of the designated page from the designated page in the target website based on the crawler service; The resource package uploaded by the crawler service is received and cached locally on the server, wherein the resource package is obtained by the crawler service packaging the page resources.
9. The method according to claim 8, It is characterized in that The resource crawling condition currently met includes at least one of the following: Currently receiving resource crawling instructions; Currently, notification information is received indicating that a page resource of a specified page in a target website has been updated.
10. The method according to claim 8, It is characterized in that The method also includes pre-configuring the crawler service based on: Install the crawler application corresponding to the crawler service in the current project based on the set installation tool; In response to completing the installation of the crawler application, configuring cache related information of the crawler service in the configuration file of the current project, the cache related information including at least one of a page link of a target crawling page, user agent information of a Webview component in a client, and server interface information; Create a new application cache file in the current project, where the application cache file is used to write related scripts; The name of the crawler application and the libraries and software development kits related to the crawler application are introduced into the relevant script.
11. The method according to claim 10, It is characterized in that The starting of the pre-configured crawler service includes: Launching a headless browser based on the crawler application; In response to the headless browser being started, creating a new tab in the headless browser; Based on the tab page, the headless browser is adjusted from a default computer mode to a mobile mode.
12. The method according to claim 11, It is characterized in that The crawling of the page resource of the designated page from the designated page in the target website based on the crawler service includes: In the newly created tab, opening the target crawling page based on the page link; In response to the target crawling page being opened, controlling the target crawling page to scroll up and down to load lazy loading resources, and monitoring response information of each request in the target crawling page; In response to monitoring the response information, acquiring the page resource from the response information based on a crawled resource type, wherein the crawled resource type is determined based on a mode of the headless browser; In response to acquiring the page resource, the page resource is stored in a local designated directory of the server, and storage file information of the page resource is recorded, wherein the storage file information includes at least one of a file link, a file name, a content type, and a character encoding.
13. A resource access device, It is characterized in that Applied to a mobile terminal, the device comprises: A resource information determination module, configured to determine target resource information of a target resource in response to an access request for accessing a target resource sent by a client being intercepted; A target resource search module, used to search for the target resource in the local storage resources of the mobile terminal based on the target resource information, wherein the local storage resources include page resources of a specified page in the target website pre-stored locally in the mobile terminal, and the page resources are obtained by a resource package pre-acquired from a server, and the resource package is obtained by the server crawling the page resources from the specified page in the target website using a crawler service; A target resource acquisition module, configured to acquire the target resource from the page resource in response to finding the target resource in the page resource; The target resource sending module is used to send the target resource to the client for access by the client.
14. The device according to claim 13, It is characterized in that The device also includes a page resource storage module; The page resource storage module includes: A resource package acquisition unit, configured to acquire the resource package from the server in response to detecting that the client is started; The page resource storage unit is used to obtain the page resource of the designated page by decompressing the resource package, and store the page resource locally in the mobile terminal.
15. The device according to claim 14, It is characterized in that The device also includes: A resource information acquisition unit, used to acquire page resource information of the page resource from the server; The resource package acquisition unit is further configured to execute the operation of acquiring the resource package from the server in response to determining that the mobile terminal currently meets the resource package acquisition condition based on the page resource information.
16. The device according to claim 15, It is characterized in that The page resource information includes a page identifier of the specified page; The mobile terminal currently meets the resource package acquisition conditions, including: The page resource is not found locally on the mobile terminal based on the page identifier.
17. The device according to claim 15, It is characterized in that The page resource information includes the page identifier of the specified page and the resource version of the page resource; The mobile terminal currently meets the resource package acquisition conditions, including: The page resource is found locally on the mobile terminal based on the page identifier, and it is determined based on the resource version that the resource version of the page resource stored locally on the mobile terminal is different from the resource version of the page resource stored on the server.
18. The device according to claim 13, It is characterized in that The device also includes: The target resource receiving module is used to send a resource acquisition request for acquiring the target resource to a server in response to the target resource not being found in the page resources, and receive the target resource returned by the server based on the resource acquisition request.
19. A resource storage device, It is characterized in that Applied to the server, the device comprises: A resource package acquisition module, configured to, in response to receiving a request message for acquiring a resource package sent by a mobile terminal, acquire the resource package cached in advance from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service; The resource package sending module is used for sending the resource package to the mobile terminal in response to obtaining the resource package, so that the mobile terminal can obtain the page resource based on the resource package and store it locally in the mobile terminal.
20. The device according to claim 19, It is characterized in that The device comprises a resource package cache module; The resource package cache module includes: A crawler service starting unit, configured to start the pre-configured crawler service in response to detecting that a resource crawling condition is currently met; A page resource crawling unit, configured to crawl page resources of the designated page from the designated page in the target website based on the crawler service; The resource package cache unit is used to receive the resource package uploaded by the crawler service and cache it locally on the server. The resource package is obtained by the crawler service packaging the page resources.
21. The device according to claim 20, It is characterized in that The resource crawling condition currently met includes at least one of the following: Currently receiving resource crawling instructions; Currently, notification information is received indicating that a page resource of a specified page in a target website has been updated.
22. The device according to claim 20, It is characterized in that The resource package cache module also includes a crawler service configuration unit; The crawler service configuration unit is used to: Install the crawler application corresponding to the crawler service in the current project based on the set installation tool; In response to completing the installation of the crawler application, configuring cache related information of the crawler service in the configuration file of the current project, the cache related information including at least one of a page link of a target crawling page, user agent information of a Webview component in a client, and server interface information; Create a new application cache file in the current project, where the application cache file is used to write related scripts; The name of the crawler application and the libraries and software development kits related to the crawler application are introduced into the relevant script.
23. The device according to claim 22, It is characterized in that The crawler service startup unit is also used for: Launching a headless browser based on the crawler application; In response to the headless browser being started, creating a new tab in the headless browser; Based on the tab page, the headless browser is adjusted from a default computer mode to a mobile mode.
24. The device according to claim 23, It is characterized in that The page resource crawling unit is also used for: In the newly created tab, opening the target crawling page based on the page link; In response to the target crawling page being opened, controlling the target crawling page to scroll up and down to load lazy loading resources, and monitoring response information of each request in the target crawling page; In response to monitoring the response information, acquiring the page resource from the response information based on a crawled resource type, wherein the crawled resource type is determined based on a mode of the headless browser; In response to acquiring the page resource, the page resource is stored in a local designated directory of the server, and storage file information of the page resource is recorded, wherein the storage file information includes at least one of a file link, a file name, a content type, and a character encoding.
25. A mobile terminal, It is characterized in that include: a processor and a memory for storing a computer program; Wherein, the processor is configured to implement, when executing the computer program: In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource; Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service; In response to finding the target resource in the page resource, acquiring the target resource from the page resource; The target resource is sent to the client for access by the client.
26. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by the processor of the mobile terminal, the following is achieved: In response to intercepting an access request sent by a client for requesting access to a target resource, determining target resource information of the target resource; Based on the target resource information, searching for the target resource in the local storage resources of the mobile terminal, the local storage resources including page resources of a specified page in the target website pre-stored locally in the mobile terminal, the page resources being obtained by a resource package pre-acquired from a server, the resource package being obtained by the server crawling page resources from the specified page in the target website using a crawler service; In response to finding the target resource in the page resource, acquiring the target resource from the page resource; The target resource is sent to the client for access by the client.
27. A server, It is characterized in that include: a processor and a memory for storing a computer program; Wherein, the processor is configured to implement, when executing the computer program: In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service; In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
28. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by the server-side processor, it realizes: In response to receiving a request message for obtaining a resource package sent by a mobile terminal, obtaining the pre-cached resource package from the local of the server, wherein the resource package includes page resources of a specified page in a target website, and the resource package is obtained by crawling the page resources from the specified page in the target website in advance using a crawler service; In response to acquiring the resource package, the resource package is sent to the mobile terminal, so that the mobile terminal obtains the page resource based on the resource package and stores it locally in the mobile terminal.
Citation Information
Patent Citations
Webpage loading and webpage data providing method and device of mobile terminal
CN104423991A
Page resource loading method and terminal equipment
CN107729352A
Loading method, system, computer device and storage medium for client H5 page
CN108520059A
Page loading method and electronic equipment
CN111143727A
Page content display method and device and electronic equipment
CN113268261A
