CN117112110A - Page-based data processing method and device and electronic equipment - Google Patents
Page-based data processing method and device and electronic equipment Download PDFInfo
- Publication number
- CN117112110A CN117112110A CN202311099320.2A CN202311099320A CN117112110A CN 117112110 A CN117112110 A CN 117112110A CN 202311099320 A CN202311099320 A CN 202311099320A CN 117112110 A CN117112110 A CN 117112110A
- Authority
- CN
- China
- Prior art keywords
- page
- pages
- path
- file
- scanning
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title abstract description 22
- 238000000034 method Methods 0.000 claims abstract description 69
- 230000006870 function Effects 0.000 claims description 49
- 238000004458 analytical method Methods 0.000 claims description 24
- 238000012545 processing Methods 0.000 claims description 18
- 101100066896 Drosophila melanogaster cher gene Proteins 0.000 claims description 17
- 238000004422 calculation algorithm Methods 0.000 claims description 8
- 230000009193 crawling Effects 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 6
- 230000008569 process Effects 0.000 description 24
- 238000011161 development Methods 0.000 description 19
- 238000010586 diagram Methods 0.000 description 8
- 238000012423 maintenance Methods 0.000 description 6
- 230000004044 response Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 239000000284 extract Substances 0.000 description 5
- 230000008859 change Effects 0.000 description 4
- 230000003993 interaction Effects 0.000 description 4
- 230000009191 jumping Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000005457 optimization Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- GNFTZDOKVXKIBK-UHFFFAOYSA-N 3-(2-methoxyethoxy)benzohydrazide Chemical compound COCCOC1=CC=CC(C(=O)NN)=C1 GNFTZDOKVXKIBK-UHFFFAOYSA-N 0.000 description 1
- YTAHJIFKAKIKAV-XNMGPUDCSA-N [(1R)-3-morpholin-4-yl-1-phenylpropyl] N-[(3S)-2-oxo-5-phenyl-1,3-dihydro-1,4-benzodiazepin-3-yl]carbamate Chemical compound O=C1[C@H](N=C(C2=C(N1)C=CC=C2)C1=CC=CC=C1)NC(O[C@H](CCN1CCOCC1)C1=CC=CC=C1)=O YTAHJIFKAKIKAV-XNMGPUDCSA-N 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 239000012141 concentrate Substances 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/50—Controlling the output signals based on the game progress
- A63F13/52—Controlling the output signals based on the game progress involving aspects of the displayed game scene
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/30—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by output arrangements for receiving control signals generated by the game device
- A63F2300/308—Details of the user interface
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The disclosure provides a data processing method and device based on a page and electronic equipment, relates to the technical field of information, and solves the technical problem of low accuracy of configuration routing information. The method comprises the following steps: acquiring directory structures of a plurality of pages in a front-end routing item; obtaining the link relation among a plurality of pages by scanning the directory structure; generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages; the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
Description
Technical Field
The disclosure relates to the field of information technology, and in particular relates to a page-based data processing method and device and electronic equipment.
Background
Currently, in today's global Wide area network (Web) applications, front-end routing management is critical to building an interactivity and complexity interface. The front-end routing is responsible for loading corresponding pages, views, layouts or components and handling navigation and hopping between pages according to changes in the uniform resource location system (uniform resource locator, URL).
Existing front-end routing typically requires manual configuration of routing information, including specifying the path and corresponding components for each page. However, as the project size increases and the relationship between pages becomes complex, manually configuring routes becomes cumbersome and error-prone, making the accuracy of configuring route information low.
Disclosure of Invention
The disclosure aims to provide a page-based data processing method and device and electronic equipment, so as to alleviate the technical problem of low accuracy of configuration routing information.
In a first aspect, an embodiment of the present disclosure provides a data processing method based on a page, where the method includes:
acquiring directory structures of a plurality of pages in a front-end routing item;
obtaining the link relation among a plurality of pages by scanning the directory structure;
generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
In a second aspect, there is provided a page-based data processing apparatus, the apparatus comprising:
the acquisition module is used for acquiring directory structures of a plurality of pages in the front-end routing item;
the scanning module is used for obtaining the link relation among a plurality of pages by scanning the directory structure;
the generation module is used for generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
In a third aspect, an embodiment of the disclosure further provides an electronic device, including a memory, and a processor, where the memory stores a computer program that can be executed by the processor, and the processor executes the method according to the first aspect.
In a fourth aspect, embodiments of the present disclosure further provide a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method of the first aspect described above.
The embodiment of the disclosure brings the following beneficial effects:
according to the data processing method and device based on the page and the electronic equipment, the directory structure of a plurality of pages in a front-end routing project can be obtained, the link relation among the plurality of pages is obtained through scanning the directory structure, a page path of a tree structure is generated according to the link relation, the page path comprises a plurality of jump paths among the plurality of pages, and the page path is used for obtaining at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can be jumped from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface. According to the scheme, the page directory structure in the front-end route project is automatically scanned, the link relation among the pages is analyzed, the page path of the tree structure containing the accurate jump path among the pages is generated, the route is generated in an automatic route mode through the generation of the page path of the tree structure, the complicated process of manual configuration is reduced, the jump relation among the pages can be more accurately processed, the path information of the pages is ensured to be accurate, the complicated and possibly occurring errors and omissions of the manual configuration route are avoided, and the technical problem of low accuracy of the configuration route information is solved.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the prior art, the drawings that are required in the detailed description or the prior art will be briefly described, it will be apparent that the drawings in the following description are some embodiments of the present disclosure, and other drawings may be obtained according to the drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a flow chart of a method for processing page-based data according to an embodiment of the disclosure;
FIG. 2 is an example of execution step correspondence code in a page-based data processing method provided by an embodiment of the present disclosure;
FIG. 3 is another example of execution step correspondence code in the page-based data processing method provided in an embodiment of the present disclosure;
FIG. 4 is another example of execution step correspondence code in the page-based data processing method provided by the embodiments of the present disclosure;
FIG. 5 is another example of execution step correspondence code in a page-based data processing method provided by an embodiment of the present disclosure;
FIG. 6 is another example of execution step correspondence code in a page-based data processing method provided by an embodiment of the present disclosure;
FIG. 7 is another example of execution step correspondence code in a page-based data processing method provided by an embodiment of the present disclosure;
FIG. 8 is a schematic diagram of a page-based data processing apparatus according to an embodiment of the present disclosure;
fig. 9 shows a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. Based on the embodiments in this disclosure, all other embodiments that a person of ordinary skill in the art would obtain without making any inventive effort are within the scope of protection of this disclosure.
The terms "comprising" and "having" and any variations thereof, as referred to in the embodiments of the disclosure, are intended to cover non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed but may optionally include other steps or elements not listed or inherent to such process, method, article, or apparatus.
Currently, web development refers to the process of building and maintaining Web applications using Web technology. Web development is an important branch of internet application program development, and relates to aspects of front-end development, back-end development, database design, network security, performance optimization and the like.
In the current Web application program, a developer is required to specify paths and components of the page one by one in a manual route configuration mode, route information is easy to miss or incorrectly configure, and the page cannot be normally loaded or jumped, so that the manual route configuration mode is complicated, errors are easy to occur, and the accuracy of configuring the route information is low.
Meanwhile, manual configuration requires a developer to have the ability to understand the relationship between the project structure and the page in a deep manner, i.e. the developer needs to know the relationship between the project structure and the page in a deep manner, the requirement on the developer is high, and configuration routing may become more difficult for newly added developers or developers unfamiliar with the project.
In the existing front-end development process, a manual configuration mode is generally adopted when lazy load routing is realized. Lazy loading, among other things, is a commonly used optimization technique that allows pages, views, layouts, or components to be loaded as needed and to improve the performance and user experience of an application. Traditional lazy load routing schemes require a developer to manually specify which pages need lazy loading and their loading opportunities. However, this manual configuration is error-prone and difficult to maintain, especially in large projects.
Because the existing front-end development process generally adopts a manual configuration mode when lazy load routing is realized, the path and the corresponding components of each page and the lazy load policy of the corresponding components are required to be specified in the routing configuration file. This manual configuration may also be manageable in small projects, but is prone to error and maintenance difficulties in large projects.
Furthermore, manually configuring routes also causes post-maintenance difficulties, and in large projects, manually maintaining a large amount of route configuration information is a heavy task, and when the relation between project structures or pages changes, the route configuration is manually updated, so that omission or inconsistency is easy to occur.
Based on the above, the embodiment of the disclosure provides a data processing method and device based on a page, and electronic equipment.
The page-based data processing method in one embodiment of the present disclosure may be run on a local terminal device or a server. When the page-based data processing method runs on a server, the method can be realized and executed based on a cloud interaction system, wherein the cloud interaction system comprises the server and client equipment.
In an alternative embodiment, various cloud applications may be run under the cloud interaction system, for example: and (5) cloud game. Taking cloud game as an example, cloud game refers to a game mode based on cloud computing. In the running mode of the cloud game, the running main body of the game program and the game picture presentation main body are separated, the storage and running of the page-based data processing method are completed on the cloud game server, and the client device is used for receiving and sending data and presenting the game picture, for example, the client device can be a display device with a data transmission function close to a user side, such as a mobile terminal, a television, a computer, a palm computer and the like; but the cloud game server which performs information processing is a cloud. When playing the game, the player operates the client device to send an operation instruction to the cloud game server, the cloud game server runs the game according to the operation instruction, codes and compresses data such as game pictures and the like, returns the data to the client device through a network, and finally decodes the data through the client device and outputs the game pictures.
In an alternative embodiment, taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used for interacting with the player through the graphical user interface, namely, conventionally downloading and installing the game program through the electronic device and running. The manner in which the local terminal device provides the graphical user interface to the player may include a variety of ways, for example, it may be rendered for display on a display screen of the terminal, or provided to the player by holographic projection. For example, the local terminal device may include a display screen for presenting a graphical user interface including game visuals, and a processor for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.
In a possible implementation manner, the embodiment of the disclosure provides a data processing method based on a page, and a graphical user interface is provided through a terminal device, where the terminal device may be the aforementioned local terminal device or the aforementioned client device in the cloud interaction system.
Embodiments of the present disclosure are further described below with reference to the accompanying drawings.
Fig. 1 is a flow chart of a data processing method based on a page according to an embodiment of the disclosure. The method can be applied to a touch terminal (such as the mobile phone 102 shown in fig. 2) capable of presenting a graphical user interface. As shown in fig. 1, the method includes:
step S110, a directory structure of a plurality of pages in the front-end routing item is obtained.
In practical application, the directory structure of a plurality of pages in the front-end routing project can be obtained in the development stage. The development stage can be a Web front-end route development stage, and corresponding pages can be loaded according to the change of the URL through the front-end route, and navigation and skip among the pages can be processed.
In step S120, the link relationship between the plurality of pages is obtained by scanning the directory structure.
As a possible implementation manner, the directory structure scanning may be performed on the front-end routing item in the development stage, and the link information in each page is recursively scanned from the page entry file, and according to the link information, the corresponding page file is further scanned until all the pages are scanned.
For example, in scanning the directory structure, the entry file for a page may be found by parsing the directory structure of the front-end item and recursively scanning the links for each page starting from the entry file. When links of pages are scanned, the content of each page is analyzed, and link information in the page is extracted, wherein the link information comprises paths for jumping to other pages. And scanning the corresponding page file according to the link information to acquire information such as components, dependencies and the like of the page.
Step S130, generating a page path of the tree structure according to the link relation.
The page path includes a plurality of skip paths between a plurality of pages. In practical application, a tree-structured page path can be constructed according to the jump relationship between pages, namely the link relationship.
As an alternative implementation mode, the nodes of the tree in the tree structure represent pages, the edges of the tree in the tree structure represent skip paths among the pages, the tree structure is gradually constructed and the paths of each page are marked through recursion scanning and analysis of link information, and the skip paths among each page can be accurately realized according to the generated page paths of the tree structure.
In practical application, the page path is used for acquiring at least one target jump path associated with the first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
When a certain page is displayed in the graphical user interface of the terminal, path information of other pages to which the page may jump is acquired from the tree structure in advance when the certain page is displayed in the graphical user interface by utilizing the generated tree structure and the page path. According to the path information, the style file and the script file of the page to be jumped are loaded in advance in an asynchronous loading mode, so that waiting time of a user is shortened, and response speed of page switching is improved.
Through analyzing other paths related to the page in the tree structure, style files and script files of other pages to be jumped to are loaded in advance, so that intelligent lazy load routing is realized, namely through analyzing the tree structure, a developer can know that paths for jumping to other pages exist in a certain page in advance, and therefore the pages to be jumped to are loaded in advance by using lazy loading.
In the embodiment of the disclosure, the page directory structure in the front-end routing project is automatically scanned, the link relation among the pages is analyzed, the page path of the tree structure containing the accurate jump path among the pages is generated, the route is generated in an automatic way through the generation of the page path of the tree structure, the complicated process of manual configuration is reduced, the jump relation among the pages can be more accurately processed, the path information of the pages is ensured to be accurate, the complicated and possibly-occurring errors and omissions of the manual configuration route are avoided, and the link of the page directory structure and the analysis page is scanned, so that the manual configuration of the route information is not needed, the workload and the possibility of mistakes of a developer are reduced, and the development efficiency is improved.
In addition, by analyzing the tree structure, paths for jumping to other pages in a certain page can be obtained in advance, so that the style files and script files of the pages to be jumped are loaded in advance by using lazy loading, the waiting time of a user is shortened, the response speed of page switching is improved, the page loading performance is improved, and intelligent generation of lazy loading routes is realized. Therefore, through the generation of the tree structure and the realization of the lazy loading route, the page to be jumped can be loaded in advance according to the jump relation among the pages, thereby remarkably reducing the loading time when the pages are switched and improving the page loading performance and the user experience. Moreover, through loading the page possibly jumped to in advance, the user can immediately present the content when navigating to the new page, the waiting time of page loading is reduced, smooth navigation experience is provided, user satisfaction and viscosity are enhanced, and user navigation experience is optimized. For single-page application programs, an efficient navigation mode is provided through lazy loading routing, namely, pages which are likely to jump are loaded in advance, a user can rapidly switch pages during navigation, the overhead of reloading the whole application is avoided, seamless navigation experience is provided, and efficient navigation supporting single-page application (SPA) is realized. According to the lazy loading routing scheme, pages which are likely to jump can be loaded in advance according to the navigation path of the user, so that the time of first loading is reduced. This is particularly important for applications with complex page structures and large amounts of resources, which can quickly present content and attract the attention of users.
In addition, the routing is generated in an automatic mode, the complicated process of manual configuration is reduced, a developer can concentrate on the realization of business logic, the development efficiency and the code quality are improved, the problems of complicated manual configuration and easy error of the routing are avoided, the development efficiency and the maintainability of codes are improved, the lazy loading routing is generated through a more efficient and intelligent solution, the workload of manual configuration is reduced, and the development efficiency and the maintainability of codes are improved. Furthermore, the lazy loading routing scheme of the method is based on a tree structure, so that a multi-level navigation menu can be easily constructed, an efficient and flexible mode is provided for managing and displaying the navigation structure for a large application program or a portal website, and the quick construction of multi-level navigation can be supported.
Furthermore, the method provided by the embodiment of the disclosure is suitable for front-end projects with various scales and complexities, greatly simplifies the work of route configuration, and improves the development efficiency and user experience. In addition, the tree structure is dynamically generated according to the actual catalog structure and page links of the project, so that the method is suitable for front-end projects with various scales and complexity, and can flexibly cope with and adapt to the change and expansion of the project structure. The method is realized based on the front-end technology, can be suitable for various front-end development frames and platforms, including but not limited to Angular, react, vue, and has wide applicability, portability and cross-platform applicability.
The above steps are described in detail below.
In some embodiments, the directory structure may be scanned by function recursion to more efficiently and accurately determine the link relationship between pages, so as to avoid omission of the page link relationship. As an example, the step S120 may include the steps of:
step a), a readdirSync function is utilized to scan a root directory of a front-end routing item, and an entry file of a page is obtained;
step b), recursively scanning a directory structure from an entry file by utilizing ScanDir function to obtain link information of a plurality of pages;
and c), determining the link relation among the pages according to the link information of the pages.
For the process of scanning the directory structure, exemplary, executing code as shown in fig. 2, the root directory of the front-end item is scanned using the readdirSync function of the fs module of node. Js to parse the directory structure of the front-end item to find the entry file of the page. A typical project entry file is src/index. Js, so links for each page can be recursively scanned starting from this path, i.e., starting from the entry file.
In the embodiment of the disclosure, the root directory is scanned through the readdirSync function to obtain the entry file of the page, and the scanning directory structure of recursion is started from the entry file through the ScanDir function, so that the link relation between the pages is more efficiently and accurately determined, and omission of the link relation between the pages is avoided.
Based on the steps a), b) and c), recursively scanning the subdirectory when the scanning result is the subdirectory until the scanning result is a file, so that the scanning process is more comprehensive, and the omission of pages in the scanning process is avoided. As an example, the above step b) may include the steps of:
step d), scanning the directory structure from the entry file by utilizing ScanDir function to obtain a scanning result;
and e), if the scanning result is the subdirectory, scanning the subdirectory recursively until the scanning result is the file.
For the process of recursively scanning the directory structure, an exemplary implementation code, as shown in FIG. 2, defines a ScanDir function to scan the directory structure that recursively scans the directory and obtains information for the file and subdirectories, and recursively scans until the final directory is a file if the subdirectories are also directories.
In the embodiment of the disclosure, when the scanning result is the subdirectory, the subdirectory is continuously and recursively scanned until the scanning result is the file, so that the scanning process is more comprehensive, and the omission of pages in the scanning process is avoided.
Based on the steps a), b) and c), the link information of the page can be extracted from the content of the page file by analyzing the content of the page file, so that the obtained page link information is more accurate. As an example, the above step b) may include the steps of:
F), recursively scanning the directory structure from the entry file by utilizing ScanDir function to obtain a page file;
and g), analyzing the content of the page files, and extracting the link information of the page from the content of each page file according to the content analysis result of the page file.
For the process of obtaining the page links, for example, when the current path is determined to be a file by using stats. Isfile () as an execution code shown in fig. 3, the content of the file may be parsed, that is, the content of each page is parsed, so as to extract link information therein, including paths to jump to other pages.
In the embodiment of the disclosure, the page link information with more accurate data can be obtained by analyzing the content of the page file and extracting the link information of the page from the content.
Based on the above steps f) and g), the parsing process of the pagefile may be implemented by the Cheerio crawling page module, so that the parsing of the pagefile is more efficient. As an example, the above step g) may include the steps of:
step h), analyzing pages in the page file by using a Cheerio grabbing page module;
step i), selecting a link element in the page through a selector, extracting an href attribute value of the link element, and determining the href attribute value as link information of the page.
In practical applications, as shown in fig. 3, the execution code may use Cheerio to parse the page, select the link element in the page through the selector, extract the href attribute thereof, store the link information, that is, the href value of the link element, in an array, and then scan the corresponding page file according to the link information, to obtain the information of the components, dependencies, etc. of the page.
In the embodiment of the disclosure, the analysis process of the page file is realized through the Cheerio grabbing page module, so that the analysis efficiency of the page file can be improved.
Based on the steps h) and i), the HTML structure in the page file can be read through the function and then processed, so that the analysis efficiency of the pages in the page file is higher. As an example, the above step h) may include the steps of:
and j), reading file content of the page file through a readFileSync function, and processing an HTML structure in the file content by utilizing a Cheerio crawling page module.
As a possible implementation manner, as shown in the execution code in FIG. 3, the file content is read through the readFileSync function of the fs module of the node. Js, and then the HTML structure in the file content is processed by using the Cheerio module, so that the analysis efficiency of the page file is improved.
Based on step j) above, the href attribute value of the link element can be determined by the a tag to obtain more accurate page link information. As an example, the above step i) may include the steps of:
step k), selecting all a tags from the HTML structure, determining the existence value in the href attribute of the a tags, and extracting the existence value in the href attribute.
In the embodiment of the disclosure, as shown in the execution code in fig. 3, the content of all the a tags and the href attribute existing values in the HTML structure is found first, and then extracted, so that the link arrays in each page that can jump to other pages can be obtained more accurately.
In some embodiments, the page paths may be generated by constructing a tree structure by a recursive algorithm so that the generated page paths more conform to the tree structure. As an example, the step S130 may include the steps of:
step l), analyzing the link relation, and constructing a tree structure by using a recursion algorithm according to the analysis result of the link relation;
and m) marking paths for each page in the tree structure to obtain a page path comprising jump paths among a plurality of pages.
For step i) above, wherein the nodes in the tree structure represent pages and the edges in the tree structure represent jumping relationships between pages.
In practical application, a tree structure can be constructed according to the skip relation among pages, wherein the nodes of the tree represent pages, and the edges represent skip paths among pages, namely, each node represents a page and contains path information thereof. And constructing a skip relation among pages by analyzing the link information of the pages, and adding the child nodes into the array of the parent nodes.
As a possible implementation, to implement the generation of the tree structure, a recursive algorithm is used to construct the skip relation among pages and add a path tag to each page, i.e. by recursively scanning and analyzing the link information, the tree structure is gradually constructed and the path of each page is tagged.
In the execution code of the above procedure as shown in fig. 4 and 5, the GetPageName function is used to obtain the name or identifier of the page, the isintellink function is used to determine whether the link is an internal link, so as to exclude the external link, and the ResolveLink function is used to parse the link to obtain the path of the target page.
In the embodiment of the disclosure, the page path is generated in a mode of constructing the tree structure through a recursion algorithm, so that the relation among all pages in the generated tree structure is more accurate.
In some embodiments, when a client displays a certain page, the tree structure of the page path can be analyzed to obtain the jump path of the page, and further, other pages to which the page can jump are loaded in advance in an asynchronous loading mode, so that the page switching delay is reduced, and the page response speed is improved. Based on this, providing a graphical user interface by the client; the client responds to the first page displayed in the graphical user interface, analyzes the tree structure of the page path, acquires at least one target jump path associated with the first page from the tree structure according to the analysis result, and loads the style file and/or script file of at least one second page which can jump to from the first page in advance in a mode of asynchronously loading the page according to the at least one target jump path.
In practical application, in order to realize lazy load routing, the generated tree structure and page paths can be utilized, and when a certain page is entered, path information of other pages possibly jumped to by the page is obtained from the tree structure, so that the other pages possibly jumped to are loaded in advance.
As a possible implementation manner, a method may be added in the tree node class of the tree structure, so as to obtain path information of other pages that may be jumped to by the current page. As shown in fig. 6, when a certain page is entered, path information of other pages to which the page may jump can be acquired. According to the acquired path information, the execution code shown in fig. 7 loads the style file and the script file of the page to be jumped in advance in an asynchronous loading mode, so as to reduce the waiting time of a user and improve the response speed of page switching.
In the code shown in FIG. 7, the loadPage function represents the method of asynchronously loading pages. And sequentially loading pages to be jumped by calling the PreloadPages function and transmitting the acquired path information, so as to reduce the waiting time of a user and improve the response speed of page switching.
In the embodiment of the disclosure, the generated tree structure and the page path are utilized to load other pages possibly jumped to by the current page in advance when entering the current page, so that lazy load routing is realized, delay of page switching is reduced, overall response speed is improved, and user experience is improved. Moreover, by only loading the pages actually accessed by the user and the related pages thereof, the pages are loaded according to the requirement, the waste of bandwidth and resources caused by loading all the pages at one time is avoided, the load pressure of the server and the network is reduced, and the consumption of network resources is saved.
In some embodiments, if the page changes, the directory structure is scanned again and the page path of the tree structure is updated dynamically according to the new link relation, so as to ensure the real-time performance and the accuracy of the page path of the tree structure. As an example, the method may further comprise the steps of:
Step n), when the page in the front-end routing item changes, rescanning the directory structure to obtain a new link relation among a plurality of pages;
and step o), updating the page paths of the tree structure according to the new link relation, wherein the page paths comprise new jump paths among a plurality of pages.
In practical application, when the front-end item changes, for example, a page is newly added or deleted, the existing tree structure is updated by rescanning the directory structure and the link relationship, so that the capability of dynamically updating and maintaining the tree structure is realized to reflect the latest page structure and the jump relationship, and the accuracy and the instantaneity of lazy load routing are ensured.
In addition, in the project iteration and maintenance process, the solution of automatically generating the route provided by the method can be quickly adapted to the change of page structure and content, support quick iteration and maintenance, and reduce the complexity of maintenance work.
The lazy loading routing scheme generated through the tree structure can also cope with the expansion and maintenance of the application program, namely, the newly added page only needs to conform to the directory structure, the manual configuration of the routing is not needed, the workload of a developer is reduced, and the expandability and maintainability of the application program are improved.
FIG. 8 provides a schematic diagram of a page-based data processing apparatus. As shown in fig. 8, the page-based data processing apparatus 800 includes:
an obtaining module 801, configured to obtain a directory structure of a plurality of pages in a front-end routing item;
a scanning module 802, configured to obtain a link relationship between a plurality of pages by scanning the directory structure;
a generating module 803, configured to generate a page path of a tree structure according to the link relationship, where the page path includes a plurality of skip paths between a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
By the method, the page directory structure in the front-end routing project is automatically scanned, the link relation among the pages is analyzed, the page path of the tree structure containing the accurate jump path among the pages is generated, the route is generated in an automatic way by generating the page path of the tree structure, the complicated process of manual configuration is reduced, the jump relation among the pages can be more accurately processed, the path information of the pages is ensured to be accurate, the complicated and possibly-occurring errors and omissions of the manual configuration route are avoided, and the page directory structure is scanned to be linked with the analysis page, so that the manual configuration of the route information is not needed, the workload of a developer and the possibility of mistakes are reduced, and the development efficiency is improved.
In one possible embodiment, the scanning module is specifically configured to:
scanning a root directory of the front-end routing item by using a readdirSync function to obtain an entry file of the page;
recursively scanning the directory structure from the entry file by utilizing ScanDir function to obtain link information of a plurality of pages;
and determining the link relation among the pages according to the link information of the pages.
In one possible embodiment, the scanning module is further configured to:
scanning the directory structure from the entry file by utilizing ScanDir function to obtain a scanning result;
and if the scanning result is a subdirectory, recursively scanning the subdirectory until the scanning result is a file.
In one possible embodiment, the scanning module is further configured to:
recursively scanning the directory structure from the entry file by using ScanDir function to obtain a page file;
and analyzing the content of the page files, and extracting the link information of the page from the content of each page file according to the content analysis result of the page files.
In one possible embodiment, the scanning module is specifically configured to:
Analyzing the pages in the page file by using a Cheerio grabbing page module;
and selecting a link element in the page through a selector, extracting an href attribute value of the link element, and determining the href attribute value as link information of the page.
In one possible embodiment, the scanning module is further configured to:
and reading the file content of the page file through a readFileSync function, and processing the HTML structure in the file content by utilizing a Cheerio crawling page module.
In one possible embodiment, the scanning module is further configured to:
and selecting all a labels from the HTML structure, determining the existence value in the href attribute of the a labels, and extracting the existence value in the href attribute.
In one possible embodiment, the generating module is specifically configured to:
analyzing the link relation, and constructing a tree structure by using a recursion algorithm according to the analysis result of the link relation, wherein nodes in the tree structure represent the pages, and edges in the tree structure represent the skip relation among a plurality of pages;
and marking the path for each page in the tree structure to obtain a page path comprising a plurality of skip paths among the pages.
In one possible embodiment, a graphical user interface is provided by a client; the client responds to the display of a first page in the graphical user interface, analyzes the tree structure of the page path, acquires at least one target jump path associated with the first page from the tree structure according to an analysis result, and loads a style file and/or a script file of at least one second page which can jump to from the first page in advance in a mode of asynchronously loading the page according to at least one target jump path.
In a possible implementation, the scanning module is further configured to rescan the directory structure when the pages in the front-end routing item change, so as to obtain a new link relationship between the pages; the apparatus further comprises: and the updating module is used for updating the page path of the tree structure according to the new link relation, wherein the page path comprises a plurality of new jump paths among the pages.
The data processing device based on the page provided by the embodiment of the disclosure has the same technical characteristics as the data processing method based on the page provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
Fig. 9 shows a schematic structural diagram of an electronic device according to an embodiment of the disclosure, including: a processor 901, a storage medium 902 and a bus 903, the storage medium 902 storing machine readable instructions executable by the processor 901, the processor 901 and the storage medium 902 communicating over the bus 903 when the electronic device runs a page based data processing method as in the embodiment, the processor 901 executing the machine readable instructions, the preamble of the processor 901 method item to perform the steps of:
acquiring directory structures of a plurality of pages in a front-end routing item;
obtaining the link relation among a plurality of pages by scanning the directory structure;
generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
In a possible embodiment, the processor, when executing the process of obtaining the link relation between the plurality of pages by scanning the directory structure, is specifically configured to:
scanning a root directory of the front-end routing item by using a readdirSync function to obtain an entry file of the page;
recursively scanning the directory structure from the entry file by utilizing ScanDir function to obtain link information of a plurality of pages;
and determining the link relation among the pages according to the link information of the pages.
In a possible embodiment, the processor, when executing a recursive scanning of the directory structure starting from the entry file using the ScanDir function, is specifically configured to:
scanning the directory structure from the entry file by utilizing ScanDir function to obtain a scanning result;
and if the scanning result is a subdirectory, recursively scanning the subdirectory until the scanning result is a file.
In a possible embodiment, the processor is specifically configured to, when performing a recursive scanning of the directory structure starting from the entry file using the ScanDir function, obtain the link information of a plurality of the pages:
Recursively scanning the directory structure from the entry file by using ScanDir function to obtain a page file;
and analyzing the content of the page files, and extracting the link information of the page from the content of each page file according to the content analysis result of the page files.
In a possible embodiment, the processor is specifically configured to, when executing parsing of the content of the pagefile, extract the link information of the page from the content of each of the pagefiles according to the content parsing result of the pagefile:
analyzing the pages in the page file by using a Cheerio grabbing page module;
and selecting a link element in the page through a selector, extracting an href attribute value of the link element, and determining the href attribute value as link information of the page.
In one possible embodiment, the processor, when executing the parsing of the pages in the pagefile using the Cheerio crawl module, is specifically configured to:
and reading the file content of the page file through a readFileSync function, and processing the HTML structure in the file content by utilizing a Cheerio crawling page module.
In a possible embodiment, the processor, when executing the selection of the link element in the page by the selector, extracts the href attribute value of the link element, is specifically configured to:
and selecting all a labels from the HTML structure, determining the existence value in the href attribute of the a labels, and extracting the existence value in the href attribute.
In a possible embodiment, the processor, when executing the page path that generates the tree structure according to the link relation, is specifically configured to:
analyzing the link relation, and constructing a tree structure by using a recursion algorithm according to the analysis result of the link relation, wherein nodes in the tree structure represent the pages, and edges in the tree structure represent the skip relation among a plurality of pages;
and marking the path for each page in the tree structure to obtain a page path comprising a plurality of skip paths among the pages.
In one possible embodiment, a graphical user interface is provided by a client; the client responds to the display of a first page in the graphical user interface, analyzes the tree structure of the page path, acquires at least one target jump path associated with the first page from the tree structure according to an analysis result, and loads a style file and/or a script file of at least one second page which can jump to from the first page in advance in a mode of asynchronously loading the page according to at least one target jump path.
In one possible embodiment, the processor is further configured to:
when the pages in the front-end routing item are changed, rescanning the directory structure to obtain a new link relation among a plurality of pages;
and updating the page paths of the tree structure according to the new link relation, wherein the page paths comprise a plurality of new jump paths among the pages.
By the method, the page directory structure in the front-end routing project is automatically scanned, the link relation among the pages is analyzed, the page path of the tree structure containing the accurate jump path among the pages is generated, the route is generated in an automatic way by generating the page path of the tree structure, the complicated process of manual configuration is reduced, the jump relation among the pages can be more accurately processed, the path information of the pages is ensured to be accurate, the complicated and possibly-occurring errors and omissions of the manual configuration route are avoided, and the page directory structure is scanned to be linked with the analysis page, so that the manual configuration of the route information is not needed, the workload of a developer and the possibility of mistakes are reduced, and the development efficiency is improved.
In practical applications, the memory 901 may include a high-speed random access memory (Random Access Memory, simply referred to as RAM), and may further include a non-volatile memory (non-volatile memory), such as at least one magnetic disk memory. The communication connection between the system network element and the at least one other network element is implemented through at least one communication interface (which may be wired or wireless), and the internet, wide area network, local network, metropolitan area network, etc. may be used.
Bus 903 may be an ISA bus, a PCI bus, or an EISA bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in fig. 9, but not only one bus or one type of bus.
The memory 901 is configured to store a program, and the processor 902 executes the program after receiving an execution instruction, where a method executed by an apparatus defined by a process disclosed in any embodiment of the disclosure may be applied to the processor 902 or implemented by the processor 902.
The processor 902 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the methods described above may be performed by integrated logic circuitry in hardware or instructions in software in the processor 902. The processor 902 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but may also be a digital signal processor (Digital Signal Processing, DSP for short), application specific integrated circuit (Application Specific Integrated Circuit, ASIC for short), off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA for short), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps and logic blocks of the disclosure in the embodiments of the disclosure may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present disclosure may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 901, and a processor 902 reads information in the memory 901, and in combination with its hardware, performs the steps of the above method.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
acquiring directory structures of a plurality of pages in a front-end routing item;
obtaining the link relation among a plurality of pages by scanning the directory structure;
generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
In a possible embodiment, the processor, when executing the process of obtaining the link relation between the plurality of pages by scanning the directory structure, is specifically configured to:
scanning a root directory of the front-end routing item by using a readdirSync function to obtain an entry file of the page;
Recursively scanning the directory structure from the entry file by utilizing ScanDir function to obtain link information of a plurality of pages;
and determining the link relation among the pages according to the link information of the pages.
In a possible embodiment, the processor, when executing a recursive scanning of the directory structure starting from the entry file using the ScanDir function, is specifically configured to:
scanning the directory structure from the entry file by utilizing ScanDir function to obtain a scanning result;
and if the scanning result is a subdirectory, recursively scanning the subdirectory until the scanning result is a file.
In a possible embodiment, the processor is specifically configured to, when performing a recursive scanning of the directory structure starting from the entry file using the ScanDir function, obtain the link information of a plurality of the pages:
recursively scanning the directory structure from the entry file by using ScanDir function to obtain a page file;
and analyzing the content of the page files, and extracting the link information of the page from the content of each page file according to the content analysis result of the page files.
In a possible embodiment, the processor is specifically configured to, when executing parsing of the content of the pagefile, extract the link information of the page from the content of each of the pagefiles according to the content parsing result of the pagefile:
analyzing the pages in the page file by using a Cheerio grabbing page module;
and selecting a link element in the page through a selector, extracting an href attribute value of the link element, and determining the href attribute value as link information of the page.
In one possible embodiment, the processor, when executing the parsing of the pages in the pagefile using the Cheerio crawl module, is specifically configured to:
and reading the file content of the page file through a readFileSync function, and processing the HTML structure in the file content by utilizing a Cheerio crawling page module.
In a possible embodiment, the processor, when executing the selection of the link element in the page by the selector, extracts the href attribute value of the link element, is specifically configured to:
and selecting all a labels from the HTML structure, determining the existence value in the href attribute of the a labels, and extracting the existence value in the href attribute.
In a possible embodiment, the processor, when executing the page path that generates the tree structure according to the link relation, is specifically configured to:
analyzing the link relation, and constructing a tree structure by using a recursion algorithm according to the analysis result of the link relation, wherein nodes in the tree structure represent the pages, and edges in the tree structure represent the skip relation among a plurality of pages;
and marking the path for each page in the tree structure to obtain a page path comprising a plurality of skip paths among the pages.
In one possible embodiment, a graphical user interface is provided by a client; the client responds to the display of a first page in the graphical user interface, analyzes the tree structure of the page path, acquires at least one target jump path associated with the first page from the tree structure according to an analysis result, and loads a style file and/or a script file of at least one second page which can jump to from the first page in advance in a mode of asynchronously loading the page according to at least one target jump path.
In one possible embodiment, the processor is further configured to:
When the pages in the front-end routing item are changed, rescanning the directory structure to obtain a new link relation among a plurality of pages;
and updating the page paths of the tree structure according to the new link relation, wherein the page paths comprise a plurality of new jump paths among the pages.
By the method, the page directory structure in the front-end routing project is automatically scanned, the link relation among the pages is analyzed, the page path of the tree structure containing the accurate jump path among the pages is generated, the route is generated in an automatic way by generating the page path of the tree structure, the complicated process of manual configuration is reduced, the jump relation among the pages can be more accurately processed, the path information of the pages is ensured to be accurate, the complicated and possibly-occurring errors and omissions of the manual configuration route are avoided, and the page directory structure is scanned to be linked with the analysis page, so that the manual configuration of the route information is not needed, the workload of a developer and the possibility of mistakes are reduced, and the development efficiency is improved.
In the embodiments of the present disclosure, the computer program may also execute other machine readable instructions when executed by a processor to perform the method as described in other embodiments, and the specific implementation of the method steps and principles are referred to in the description of the embodiments and are not described in detail herein.
In the embodiments provided in the present disclosure, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
As another example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments provided in the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present disclosure may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the page-based data processing method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be noted that: like reference numerals and letters in the following figures denote like items, and thus once an item is defined in one figure, no further definition or explanation of it is required in the following figures, and furthermore, the terms "first," "second," "third," etc. are used merely to distinguish one description from another and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present disclosure, and are not intended to limit the scope of the disclosure, but the present disclosure is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, it is not limited to the disclosure: any person skilled in the art, within the technical scope of the disclosure of the present disclosure, may modify or easily conceive changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features thereof; such modifications, changes or substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present disclosure. Are intended to be within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.
Claims (13)
1. A method of page-based data processing, the method comprising:
acquiring directory structures of a plurality of pages in a front-end routing item;
obtaining the link relation among a plurality of pages by scanning the directory structure;
generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
2. The method of claim 1, wherein the step of obtaining a link relationship between a plurality of the pages by scanning the directory structure comprises:
scanning a root directory of the front-end routing item by using a readdirSync function to obtain an entry file of the page;
recursively scanning the directory structure from the entry file by utilizing ScanDir function to obtain link information of a plurality of pages;
And determining the link relation among the pages according to the link information of the pages.
3. The method of claim 2, wherein the step of recursively scanning the directory structure from the entry file using a ScanDir function comprises:
scanning the directory structure from the entry file by utilizing ScanDir function to obtain a scanning result;
and if the scanning result is a subdirectory, recursively scanning the subdirectory until the scanning result is a file.
4. The method of claim 2, wherein said step of recursively scanning said directory structure from said portal file using ScanDir function to obtain linking information for a plurality of said pages comprises:
recursively scanning the directory structure from the entry file by using ScanDir function to obtain a page file;
and analyzing the content of the page files, and extracting the link information of the page from the content of each page file according to the content analysis result of the page files.
5. The method of claim 4, wherein the step of parsing the contents of the pagefiles and extracting the link information of the pages from the contents of each of the pagefiles according to the content parsing result of the pagefiles comprises:
Analyzing the pages in the page file by using a Cheerio grabbing page module;
and selecting a link element in the page through a selector, extracting an href attribute value of the link element, and determining the href attribute value as link information of the page.
6. The method of claim 5, wherein the step of parsing the pages in the pagefile using a Cheerio crawling page module comprises:
and reading the file content of the page file through a readFileSync function, and processing the HTML structure in the file content by utilizing a Cheerio crawling page module.
7. The method of claim 6, wherein the step of extracting the href attribute value of the link element by selecting the link element in the page through a selector comprises:
and selecting all a labels from the HTML structure, determining the existence value in the href attribute of the a labels, and extracting the existence value in the href attribute.
8. The method of claim 1, wherein the step of generating a tree-structured page path from the link relationship comprises:
analyzing the link relation, and constructing a tree structure by using a recursion algorithm according to the analysis result of the link relation, wherein nodes in the tree structure represent the pages, and edges in the tree structure represent the skip relation among a plurality of pages;
And marking the path for each page in the tree structure to obtain a page path comprising a plurality of skip paths among the pages.
9. The method of claim 1, wherein the graphical user interface is provided by a client; the client responds to the display of a first page in the graphical user interface, analyzes the tree structure of the page path, acquires at least one target jump path associated with the first page from the tree structure according to an analysis result, and loads a style file and/or a script file of at least one second page which can jump to from the first page in advance in a mode of asynchronously loading the page according to at least one target jump path.
10. The method as recited in claim 1, further comprising:
when the pages in the front-end routing item are changed, rescanning the directory structure to obtain a new link relation among a plurality of pages;
and updating the page paths of the tree structure according to the new link relation, wherein the page paths comprise a plurality of new jump paths among the pages.
11. A page-based data processing apparatus, the apparatus comprising:
The acquisition module is used for acquiring directory structures of a plurality of pages in the front-end routing item;
the scanning module is used for obtaining the link relation among a plurality of pages by scanning the directory structure;
the generation module is used for generating a page path of a tree structure according to the link relation, wherein the page path comprises a plurality of skip paths among a plurality of pages;
the page path is used for acquiring at least one target jump path associated with a first page through analyzing the tree structure so as to load at least one second page which can jump to from the first page in advance through the target jump path; the first page is a page displayed in a graphical user interface.
12. An electronic device comprising a memory, a processor, the memory having stored therein a computer program executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1 to 10 when executing the computer program.
13. A computer readable storage medium storing computer executable instructions which, when invoked and executed by a processor, cause the processor to perform the method of any one of claims 1 to 10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311099320.2A CN117112110A (en) | 2023-08-29 | 2023-08-29 | Page-based data processing method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311099320.2A CN117112110A (en) | 2023-08-29 | 2023-08-29 | Page-based data processing method and device and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117112110A true CN117112110A (en) | 2023-11-24 |
Family
ID=88797990
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311099320.2A Pending CN117112110A (en) | 2023-08-29 | 2023-08-29 | Page-based data processing method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117112110A (en) |
-
2023
- 2023-08-29 CN CN202311099320.2A patent/CN117112110A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110309451B (en) | Method and device for generating web preloading page | |
US20130132422A1 (en) | System and method for creating and controlling an application operating on a plurality of computer platform types | |
CN110955428A (en) | Page display method and device, electronic equipment and medium | |
CN112416425B (en) | APP construction method and device, computer equipment and storage medium | |
CN103078945B (en) | To the method and system that browser crash data processes | |
CN104077387A (en) | Webpage content display method and browser device | |
CN103177115B (en) | A kind of method and apparatus extracting Webpage link | |
CN111680253A (en) | Page application data packet generation method and device, computer equipment and storage medium | |
CN111367595B (en) | Data processing method, program running method, device and processing equipment | |
CN110941779B (en) | Page loading method and device, storage medium and electronic equipment | |
CN110888645A (en) | Method, device and storage medium for converting into small program | |
CN112799663A (en) | Page display method and device, computer readable storage medium and electronic equipment | |
CN115982491A (en) | Page updating method and device, electronic equipment and computer readable storage medium | |
US11909640B2 (en) | Creating endpoints | |
Brodt et al. | The TELAR mobile mashup platform for Nokia internet tablets | |
CN112069236B (en) | Method, device, equipment and storage medium for displaying associated files | |
CN114637499B (en) | Visualization component processing method, device, equipment and medium | |
CN117112110A (en) | Page-based data processing method and device and electronic equipment | |
CN113934959B (en) | Program preview method and device, computer equipment and storage medium | |
CN114461960B (en) | Page generation method, page display method and page display device | |
CN115202756A (en) | Vue-based component loading method and system and electronic equipment | |
CN112732254B (en) | Webpage development method, webpage development device, computer equipment and storage medium | |
CN115186214A (en) | Page configuration method and device, computer equipment and computer readable storage medium | |
CN114168875A (en) | Page program generation method and device, computer equipment and storage medium | |
CN115080154A (en) | Page display method and device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |