Webpage simplification method, device and electronic equipment

By parsing the webpage source code to generate a node tree and pruning nodes without target attributes, the problem of low efficiency in webpage simplification in existing technologies is solved, achieving the effect of simplifying webpages and making it easier for specific users to quickly find content.

CN114691137BActive Publication Date: 2025-11-11AGRICULTURAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210355590.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-06
Publication Date
2025-11-11
Estimated Expiration
2042-04-06

AI Technical Summary

Technical Problem

Existing technologies cannot efficiently simplify web pages, making it difficult for older adults, the visually impaired, and those with dyslexia to quickly find the content they need.

Method used

By parsing the webpage source code to generate a node tree, pruning nodes without target attributes, generating a new node tree with a reduced number of nodes, and adding accessibility attributes, a simplified webpage is generated.

Benefits of technology

It achieves efficient simplification of web pages, making it easier for the elderly, visually impaired, and people with dyslexia to quickly find the content they need.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691137B_ABST
    Figure CN114691137B_ABST
Patent Text Reader

Abstract

This application discloses a webpage simplification method, apparatus, and electronic device. The method includes: obtaining a first source code of a first webpage; parsing the first source code to obtain a first node tree corresponding to the first webpage; processing the first node tree to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree; and obtaining a second source code based on the second node tree, wherein the second source code is used to obtain a second webpage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a method, apparatus and electronic device for simplifying web pages. Background Technology

[0002] With the development of the Internet, web pages are being used more and more widely.

[0003] However, due to the large amount of content presented on the webpage, users such as the elderly, visually impaired, and those with dyslexia are unable to quickly find the information they need.

[0004] Therefore, there is an urgent need for a technical solution that can efficiently simplify web pages. Summary of the Invention

[0005] In view of this, this application provides a webpage simplification method, apparatus, and electronic device to solve the problem that existing technologies cannot efficiently simplify webpages, as follows:

[0006] This application provides a method for simplifying web pages, the method comprising:

[0007] Obtain the first source code of the first webpage;

[0008] The first source code is parsed to obtain the first node tree corresponding to the first webpage;

[0009] The first node tree is processed to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree.

[0010] Based on the second node tree, the second source code is obtained, and the second source code is used to obtain the second webpage.

[0011] The above method, preferably, involves processing the first node tree to obtain a second node tree, including:

[0012] Traverse the first node tree to obtain the node attributes corresponding to each tree node in the first node tree;

[0013] Filter out the tree nodes in the first node tree that are marked with the target attribute;

[0014] A second node tree is generated based on the tree nodes marked with target attributes, whereby the target attributes are used to indicate that the web page content corresponding to the tree node should be retained.

[0015] In the above method, preferably, the tree node is marked with the target attribute in the following manner:

[0016] Before obtaining the first source code of the first webpage, receive a marked input operation for the first source code;

[0017] According to the marked input operation, the target attribute is marked on the first source code so that the tree node of the first node tree corresponding to the first webpage is marked with the target attribute.

[0018] In the above method, preferably, the tree node is marked with the target attribute in the following manner:

[0019] Before obtaining the first source code of the first webpage, the target attributes are marked on the first source code of the first webpage according to the preset retention marking rules, so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attributes.

[0020] Preferably, in the above method, after filtering out the tree nodes marked with the target attribute in the first node tree, and before generating the second node tree based on the tree nodes marked with the target attribute, the method further includes:

[0021] Add accessibility attributes to the tree nodes marked with target attributes, and the accessibility attributes enable the web page content corresponding to the tree nodes to be recognized.

[0022] The above method, preferably, further includes the following steps before obtaining the first source code of the first webpage:

[0023] Monitor whether the conditions for webpage simplification are met;

[0024] If the webpage simplification conditions are met, then the following step is executed: obtain the first source code of the first webpage;

[0025] If the webpage simplification conditions are not met, return to the previous step: monitor whether the webpage simplification conditions are met.

[0026] In the above method, preferably, the webpage simplification conditions include:

[0027] The current time of the first webpage reaches the preset target time;

[0028] Alternatively, the first duration reaches a preset target duration. The first duration begins to be recorded when the first webpage is first published and restarts after each target step is executed. The target step is: to obtain the second source code based on the second node tree.

[0029] Alternatively, the content on the first webpage that needs to be retained on the second webpage is detected to have changed;

[0030] Alternatively, a simplification trigger operation may be received, which indicates that the first webpage should be simplified.

[0031] The above method, preferably, involves obtaining the second source code based on the second node tree, including:

[0032] Traverse each tree node in the second node tree to obtain the node attributes and node type of each tree node in the second node tree;

[0033] Based on the node attributes and node type of the tree nodes, obtain the node code corresponding to each tree node in the second node tree;

[0034] The second source code is obtained based on the node codes corresponding to all tree nodes in the second node tree.

[0035] This application provides a webpage simplification device, the device comprising:

[0036] The first source code acquisition unit is used to obtain the first source code of the first webpage.

[0037] The first source code parsing unit is used to parse the first source code to obtain the first node tree corresponding to the first webpage;

[0038] A node tree processing unit is used to process the first node tree to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree.

[0039] The second source code acquisition unit is used to obtain the second source code based on the second node tree, and the second source code is used to obtain the second webpage.

[0040] This application provides an electronic device, including:

[0041] A memory used to store computer programs and the data generated by the execution of said computer programs;

[0042] A processor is configured to execute the computer program to: obtain a first source code of a first webpage; parse the first source code to obtain a first node tree corresponding to the first webpage; process the first node tree to obtain a second node tree; wherein the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree; and obtain a second source code based on the second node tree, wherein the second source code is used to obtain a second webpage.

[0043] As can be seen from the above technical solution, in the webpage simplification method, apparatus, and electronic device provided in this application, after parsing the first source code corresponding to the first webpage and obtaining the first node tree corresponding to the first webpage, the first node tree is processed to obtain a second node tree with a smaller number of tree nodes. Based on the second source code corresponding to the second node tree, a corresponding second webpage is obtained. Since the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree, the second webpage is simplified relative to the first webpage. Therefore, this application achieves the purpose of simplifying the webpage by reducing the number of tree nodes in the node tree corresponding to the webpage. Attached Figure Description

[0044] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This is a flowchart illustrating the implementation of a webpage simplification method disclosed in Embodiment 1 of this application;

[0046] Figure 2 This is a partial flowchart of a webpage simplification method disclosed in Embodiment 1 of this application;

[0047] Figure 3 This is a schematic diagram of the processing procedure of the first node tree in Embodiment 1 of this application;

[0048] Figure 4 This is a flowchart illustrating another implementation of a webpage simplification method disclosed in Embodiment 1 of this application;

[0049] Figure 5 This is a partial flowchart of a webpage simplification method disclosed in Embodiment 1 of this application;

[0050] Figure 6 This is a flowchart illustrating another implementation of a webpage simplification method disclosed in Embodiment 1 of this application;

[0051] Figure 7 This is a partial flowchart of a webpage simplification method disclosed in Embodiment 1 of this application;

[0052] Figure 8 This is a schematic diagram of the structure of a webpage simplification device disclosed in Embodiment 2 of this application;

[0053] Figure 9 This is another structural schematic diagram of a webpage simplification device disclosed in Embodiment 2 of this application;

[0054] Figure 10 This is another structural schematic diagram of a webpage simplification device disclosed in Embodiment 2 of this application;

[0055] Figure 11 This is another structural schematic diagram of a webpage simplification device disclosed in Embodiment 2 of this application;

[0056] Figure 12 This is a schematic diagram of the structure of a webpage simplification electronic device disclosed in Embodiment 3 of this application;

[0057] Figure 13 This is a flowchart illustrating the process applicable to the webpage simplification system of this application;

[0058] Figure 14 The following is a flowchart illustrating the implementation of the simplified webpage system for this application. Detailed Implementation

[0059] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0060] refer to Figure 1 The diagram shown is a flowchart illustrating the implementation of a webpage simplification method according to Embodiment 1 of this application. This method is applicable to electronic devices, such as servers, that possess HyperText Markup Language (HTML) webpage processing capabilities. The technical solution in this embodiment primarily addresses the problem of the inability to efficiently simplify webpages in the prior art.

[0061] Specifically, the method in this embodiment may include the following steps:

[0062] Step S101: Obtain the first source code of the first webpage.

[0063] The first webpage is the one that needs to be simplified, and the source code corresponding to the first webpage is the first source code.

[0064] Specifically, in this embodiment, a request message can be sent to the server corresponding to the first webpage, that is, an HTTP request can be made to the first webpage, and then the first source code corresponding to the first webpage can be obtained from the server.

[0065] Step S102: Parse the first source code to obtain the first node tree corresponding to the first webpage.

[0066] Specifically, in this embodiment, the first source code can be parsed by a tag parser to obtain the hypertext tags corresponding to the first source code, i.e., HTML tags. Then, the HTML tags are sent to the node tree builder through the communication mechanism between program modules (such as function calls). The node tree builder then constructs these HTML tags into a node tree, i.e., the first node tree.

[0067] The tag parser can be implemented using a tokenization algorithm, and the node tree builder can be implemented using a node tree construction algorithm.

[0068] It should be noted that the algorithm for parsing the first source code is not limited to the tokenization algorithm; other algorithms that can achieve the same effect can also be used. Similarly, the algorithm for constructing HTML tags into a node tree is not limited to the node tree construction algorithm; other algorithms that can achieve the same effect can also be used.

[0069] Step S103: Process the first node tree to obtain the second node tree.

[0070] In this embodiment, the tree nodes in the first node tree can be pruned to obtain a second node tree with a reduced number of tree nodes.

[0071] Specifically, in this embodiment, the node attributes corresponding to the tree nodes in the first node tree are first obtained. Then, the tree nodes without target attributes are pruned from the first node tree. Based on the remaining tree nodes with target attributes, a second node tree is generated. The number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree.

[0072] Step S104: Obtain the second source code based on the second node tree.

[0073] The second source code is used to obtain the second webpage.

[0074] In this specific implementation, the tree nodes in the second node tree are processed to obtain the node code corresponding to the tree nodes. Based on this, after obtaining the node code corresponding to all the tree nodes in the second node tree, the second source code corresponding to the second node tree is obtained.

[0075] Based on this, users can access the second source code on the server through electronic devices with web browsing tools installed, and then use the web browsing tools to translate the second source code into a second webpage that can be browsed.

[0076] For example, on an electronic device with a web browser installed, a user can access a webpage through the web browser, manually select a simplified control on the webpage to instruct the web browser to access the source code of the simplified version of the webpage on the web server. Based on this, the user uses the web browser to translate the source code of the simplified webpage into a simplified webpage for the customer to browse.

[0077] As can be seen from the above technical solution, in the webpage simplification method provided in this embodiment, after parsing the first source code corresponding to the first webpage into a first node tree corresponding to the first webpage, the first node tree is processed to obtain a second node tree with fewer tree nodes than the first node tree. Therefore, the second node tree is simplified compared to the first node tree. It is evident that in this embodiment, by reducing the number of tree nodes in the node tree corresponding to the webpage, the purpose of simplifying the webpage is achieved. Compared to the webpage before simplification, this makes it easier for elderly, visually impaired, and dyslexic users to quickly find the content they need from the webpage content.

[0078] exist Figure 1 In the implementation method, step S103 can be specifically implemented through the following steps, such as... Figure 2 As shown:

[0079] Step S301: Traverse the first node tree to obtain the node attributes corresponding to each tree node in the first node tree.

[0080] In this specific implementation, the breadth-first traversal algorithm can be used to traverse each tree node in the first node tree to obtain the node attributes corresponding to each tree node.

[0081] Step S302: Filter out the tree nodes in the first node tree that are marked with the target attribute.

[0082] The target attribute exists in the node attributes of at least some of the tree nodes in the first node tree. Therefore, based on the node attributes corresponding to the tree nodes, the tree nodes in the first node tree marked with the target attribute are selected.

[0083] The target attribute indicates which webpage content corresponding to the tree node it belongs to needs to be retained. Specifically, in this embodiment, filtering tree nodes marked with the target attribute can be performed during the traversal of the first node tree. For example, during the traversal of the first node tree, when a tree node is obtained, it is determined whether the node's attributes contain the target attribute. If the target attribute is not present, the tree node is filtered out; if the target attribute is present, the tree node is retained. Thus, through the traversal of the first node tree, all tree nodes in the first node tree have undergone the determination of whether they possess the target attribute, thereby filtering out tree nodes marked with the target attribute from the tree nodes of the first node tree.

[0084] Step S303: Generate a second node tree based on these tree nodes marked with target attributes.

[0085] In this specific implementation, a second node tree is generated based on the selected tree nodes marked with the target attribute. Since the second node tree only contains tree nodes marked with the target attribute, while tree nodes without the target attribute are filtered out, the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree.

[0086] For example, such as Figure 3 The diagram illustrates the process of generating the second node tree: dashed circles represent tree nodes without target attributes, while solid circles represent tree nodes with target attributes. During the traversal of the first node tree, tree nodes without target attributes are directly pruned. The child nodes of these unlabeled nodes are pruned along with their parent nodes; that is, when a tree node is pruned, its child nodes are also pruned. The first node tree after pruning the unlabeled tree nodes becomes the second node tree. In other words, unlabeled tree nodes and their child nodes will no longer participate in subsequent operations.

[0087] exist Figure 1 In the implementation method, before step S101, the following steps are also included, such as... Figure 4 As shown:

[0088] Step S105: Mark the target attribute for the first source code corresponding to the first webpage.

[0089] The target attribute is used to mark the source code corresponding to the content that needs to be retained in the first webpage, so as to indicate that the webpage content corresponding to the tree node it belongs to needs to be retained.

[0090] In one implementation, when marking target attributes for the first source code corresponding to the first webpage, it can be done in the following way:

[0091] Receive a tagging input operation for the first source code; based on the tagging input operation, tag the target attribute on the first source code so that the tree node of the first node tree corresponding to the first webpage is tagged with the target attribute.

[0092] Specifically, in this embodiment, before executing step S101, target attributes are added to the source code corresponding to the content to be retained in the first webpage according to the received tag input operation. Then, steps S101-S102 are executed so that the tree nodes corresponding to the content to be retained in the first webpage in the generated first node tree are tagged with target attributes.

[0093] For example, taking the execution of the method in this embodiment in a webpage output by a web browser as an example, before the web server starts to obtain the source code corresponding to the webpage, the technicians will write the target attributes into the source code corresponding to the webpage in advance, so that at least some of the tree nodes in the node tree generated later are marked with the target attributes. Based on the tree nodes marked with the target attributes, the webpage is simplified, and the user can browse the simplified webpage through the web browser.

[0094] In another implementation, the method for marking target attributes for the first source code corresponding to the first webpage includes:

[0095] Before obtaining the first source code of the first webpage, the target attributes are marked on the first source code of the first webpage according to the preset retention marking rules, so that at least some tree nodes of the first node tree corresponding to the first webpage are marked with the target attributes.

[0096] In this embodiment, specific rules for retaining tree nodes are pre-defined in the retention tagging rules. Based on this, a program with retention tagging rules can be set in the first webpage. When the first webpage is first published, the first source code corresponding to the first webpage is written to the target attributes by the program with retention tagging rules, where the retention tagging rules are set according to the content of the webpage. For example, the retention tagging rules may include the following rule: the webpage content contains a theme and an advertisement; the theme needs to be displayed in the simplified webpage, while the advertisement does not need to be displayed in the simplified webpage. Based on this, the program with retention tagging rules marks the target attributes of the source code corresponding to the theme content in the first webpage, while the source code corresponding to the advertisement content in the first webpage is not processed.

[0097] exist Figure 2 In the implementation method, after step S102 and before step S103, the following steps are also included, such as... Figure 5 As shown:

[0098] Step S304: Add the corresponding accessibility attribute to the tree node marked with the target attribute.

[0099] The accessibility attribute enables the webpage content corresponding to its tree node to be identified.

[0100] Specifically, in this embodiment, after obtaining the tree nodes marked with the target attribute in the first node tree, accessibility attributes are added to the nodes marked with the target attribute according to the ARIA attribute table using the WAI-ARIA (Web Accessibility Initiative-Accessible Rich Internet Applications) technology. The ARIA attribute table is a key-value pair table; for example, if the attribute is "button" and the attribute value is "aria-button," a screen reader can recognize it as a button based on the "aria-button" attribute.

[0101] For example, after obtaining the tree nodes marked with the target attribute in the first node tree corresponding to the first webpage, the node attribute of a certain tree node marked with the target attribute is first obtained. Then, the corresponding accessibility attribute value is matched from the ARIA attribute table according to the node attribute of the tree node, and the accessibility attribute value is added to the tree node. In this way, accessibility attributes are added to all tree nodes marked with the target attribute so that the webpage content can be recognized by the assistive devices of the webpage.

[0102] Accessible devices for web pages include screen reading devices, screen magnifying devices, and voice control devices. Screen reading devices are used to read web page content for visually impaired individuals, screen magnifying devices are used to enlarge web page content for visually impaired individuals, and voice control devices enable people with physical disabilities to operate web pages via voice.

[0103] For example, the method to add an accessibility attribute to a tree node marked with a target attribute is as follows:

[0104] Using the original input box label as <input> For example, after adding the ARIA attribute, it becomes... <input aria-valuemin="0”aria-valuemax=100> The added attribute indicates the maximum and minimum values ​​allowed for the input box.

[0105] exist Figure 4 In the implementation method, after step S105 and before step S101, the following steps may also be included, such as... Figure 6 As shown:

[0106] S106: Monitor whether the webpage simplification conditions are met. If the webpage simplification conditions are met, execute step S101. If the webpage simplification conditions are not met, continue to monitor whether the webpage simplification conditions are met, that is, continue to execute step S106.

[0107] The webpage simplification condition is the timing condition for determining whether to simplify the first webpage. It can also be understood as the execution steps: determining the timing condition for obtaining the first source code corresponding to the first webpage; if the webpage simplification condition is met, execute steps S101-S104, that is, obtain the first source code corresponding to the first webpage and simplify the first webpage according to the first source code; if the webpage simplification condition is not met, continue monitoring and waiting until the webpage simplification condition is met, then execute steps S101-S104, that is, obtain the first source code corresponding to the first webpage and simplify the first webpage according to the first source code.

[0108] In a specific implementation, the webpage simplification conditions in this embodiment can be:

[0109] The current time of the first webpage reaches the preset target time.

[0110] The preset target time refers to a specific time within a time period, such as 2:00 AM every day, 2:00 AM on Monday of every week, or 2:00 AM on the 1st of every month, etc. Each time period can have multiple target times, such as 2:00 AM on any one of Mondays, Wednesdays, and Fridays of every week. Of course, the specific time is not limited to 2:00 AM and can be other times as well. The current time refers to the current time displayed on the electronic device using the method of this embodiment. Based on this, if the current time of the electronic device using the method of this embodiment reaches the preset target time, it can be determined that the webpage simplification condition has been met. At this time, the electronic device begins to execute the method of this embodiment, that is, to simplify the first webpage.

[0111] In this specific implementation, before executing step S101, the webpage simplification conditions of the first page can be continuously monitored to see if they are met. For example, whether the current time has reached 2:00 AM of the current day, or whether the current time has reached 2:00 AM of any one of the Monday, Wednesday, or Friday of the current week, etc. If the current time of the first webpage has reached 2:00 AM of the current day, then step S101 and subsequent steps can be executed once. If the current time of the first webpage has not reached 2:00 AM, then the monitoring continues to check whether the current time has reached 2:00 AM until the current time of the first webpage reaches 2:00 AM, at which point step S101 and subsequent steps are executed once, and then the monitoring continues to check whether the current time of the first webpage has reached 2:00 AM. In other words, each time a preset target time is reached, the first source code corresponding to the first webpage is obtained once, and the first webpage is simplified based on the first source code.

[0112] For example, taking a webpage displayed by a web browser installed on an electronic device as an example, the preset condition for webpage simplification is that the webpage is simplified at 2:00 AM every day. When the time displayed on the electronic device reaches 2:00 AM, the webpage simplification condition is met, the web server begins to retrieve the source code corresponding to the webpage, and then simplifies the webpage based on the source code. Based on this, the user can view the simplified webpage through the browser.

[0113] In another implementation, the webpage simplification condition can be:

[0114] The first duration reaches the preset target duration. The first duration begins to be recorded when the first webpage is first published and restarts after each target step is executed. The target step is step S104.

[0115] Specifically, the first duration begins to be recorded when the first webpage is first published, and resumes recording after the target step is executed once. For example, the first duration begins to be recorded when the first webpage is first published, and when the preset target duration is reached, step S101 is executed, and the first duration begins to be recorded again after step S104 is executed.

[0116] For example, a preset duration, such as 24 hours or 48 hours, is set. When the first webpage is first published, the first duration is recorded. When the first duration reaches 24 hours, the first source code of the first webpage is retrieved and simplified based on it. After obtaining the second webpage, the first duration is reset to zero, and recording the first duration begins again. If the first duration does not reach the target duration, the process continues until it does. Then, the first source code of the first webpage is retrieved again, and the webpage is simplified based on it. After obtaining the second webpage, recording the first duration begins again, and so on. In other words, the first source code of the first webpage is retrieved and simplified every preset duration.

[0117] In another implementation, the webpage simplification condition can be:

[0118] The content that should be retained on the first webpage but is now on the second webpage has been detected to have changed.

[0119] Specifically, a monitoring program is set up in the first webpage to monitor changes in the content that needs to be retained in the second webpage. These changes include additions, deletions, and alterations of the content. If the monitoring program detects a change in the content, fulfilling the webpage simplification conditions, it instructs the execution of step S101 and subsequent steps. If the program does not detect a change, it continues monitoring until another change is detected, at which point it instructs the execution of step S101 and subsequent steps, and so on. In other words, whenever the monitoring program detects a change in the content, it retrieves the first source code of the first webpage and simplifies it based on that code.

[0120] For example, taking a webpage displayed in a web browser installed on an electronic device as an example, monitoring whether the content to be retained in the simplified webpage has changed can be achieved through a program or chip with webpage content monitoring capabilities. For instance, when it is detected that the content to be retained in the simplified webpage has been added, reduced, or changed—such as updating the webpage with today's latest news or deleting malicious comments from the comment section—the monitoring program or chip instructs the webpage server to obtain the first source code corresponding to the first webpage and simplify the first webpage based on that source code. Accordingly, the user can then view the simplified webpage through a web browser.

[0121] In another implementation, webpage simplification conditions may include:

[0122] A simplification trigger operation is received, wherein the simplification trigger operation is used to instruct the first webpage to be simplified, that is, to start the operation of step S101.

[0123] The first webpage includes control controls that developers can select from. A simplified trigger control on the first webpage indicates the start of the method described in this embodiment, i.e., the start of step S101.

[0124] Based on this, in this embodiment, when the simplification trigger control is selected, i.e., when the webpage simplification condition is met, step S101 and subsequent steps are executed. Then, step S101 and subsequent steps are executed again until the simplification trigger control is selected again. In other words, as long as the simplification trigger control is selected, the first source code of the first webpage is obtained once, and the first webpage is simplified once based on the first source code.

[0125] For example, when a web developer needs to simplify a webpage, the developer can manually select the "Simplify" trigger button on the webpage. In response to the generated simplification trigger operation, the webpage server will start to retrieve the source code corresponding to the webpage from the webpage server and simplify the webpage based on the source code. Based on the generated new source code, the user can view the simplified webpage through a web browser.

[0126] It should be noted that, in practical applications, the webpage simplification conditions of the method in this embodiment can be any one or any combination of the above four types, or other simplification conditions other than the above four types, in order to indicate the start of execution of the method in this embodiment.

[0127] exist Figure 6 In the implementation method, step S104 can be specifically implemented through the following steps, such as... Figure 7 As shown:

[0128] Step S701: Traverse each tree node in the second node tree to obtain the node attributes and node type of each tree node in the second node tree.

[0129] Specifically, in this embodiment, the tree nodes in the second node tree are traversed using a breadth-first traversal algorithm. Each time a tree node in the second node tree is traversed, the node attributes and node type corresponding to that tree node are obtained. Then, step S702 is executed, and then step S701 is returned to be executed. This process is repeated until all tree nodes in the second node tree have been traversed.

[0130] Step S702: Obtain the node code corresponding to each tree node in the second node tree based on the node attributes and node type of the tree node.

[0131] In the specific implementation, the node code corresponding to the tree node is generated based on the node attributes and node type of the tree node in the obtained second node tree.

[0132] For example, the method to obtain the node code corresponding to a tree node is as follows:

[0133] Taking a button node as an example, it has two attributes: one is the internal text attribute with "Submit", and the other is the aria-button attribute with "Button". The generated HTML node code would be:

[0134] <button aria-button="按钮”> submit< / button> .

[0135] Step S703: Obtain the second source code based on the node codes corresponding to all tree nodes in the second node tree.

[0136] The node codes corresponding to all tree nodes in the second node tree together constitute the second source code corresponding to the second node tree. In other words, after obtaining the node codes corresponding to all tree nodes in the second node tree, the second source code is obtained.

[0137] refer to Figure 8 The diagram shown is a structural schematic of a webpage simplification device provided in Embodiment 2 of this application. This device is suitable for electronic devices with HTML webpage processing capabilities, such as servers. The technical solution in this embodiment is mainly used to solve the problem that existing technologies cannot efficiently simplify webpages.

[0138] Specifically, the apparatus in this embodiment may include the following units:

[0139] The first source code acquisition unit 801 is used to obtain the first source code of the first webpage;

[0140] The first source code parsing unit 802 is used to parse the first source code to obtain the first node tree corresponding to the first webpage;

[0141] The node tree processing unit 803 is used to process the first node tree to obtain a second node tree; wherein the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree.

[0142] The second source code acquisition unit 804 is used to obtain the second source code based on the second node tree, wherein the second source code is used to obtain the second webpage.

[0143] As can be seen from the above technical solution, in the webpage simplification device provided in the embodiment, the first source code parsing unit parses the first source code of the first webpage obtained by the first source code obtaining unit to obtain a first node tree corresponding to the first source code. Then, the node tree processing unit processes the first node tree to obtain a second node tree with fewer tree nodes than the first node tree. Finally, the second source code obtaining unit obtains the second source code based on the second node tree, so that the webpage obtaining unit obtains the corresponding second webpage based on the second source code. Based on this, the second webpage is simplified relative to the first webpage. It is evident that this embodiment simplifies the webpage by reducing the number of tree nodes in the node tree corresponding to the webpage. Compared to the webpage before simplification, this makes it easier for elderly, visually impaired, and dyslexic users to quickly find the content they need from the webpage.

[0144] In one implementation, the node tree processing unit 803 is specifically used to: traverse the first node tree to obtain the node attributes corresponding to each tree node in the first node tree;

[0145] Filter out the tree nodes in the first node tree that are marked with the target attribute;

[0146] A second node tree is generated based on the tree nodes marked with target attributes, where the target attributes are used to indicate that the web page content corresponding to the tree node should be retained.

[0147] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 9 As shown:

[0148] The attribute tagging unit 805 is used to receive tagging input operations for the first source code before obtaining the first source code of the first webpage;

[0149] According to the tag input operation, the attribute tagging unit 806 tags the target attribute on the first source code so that the tree node of the first node tree corresponding to the first webpage is marked with the target attribute.

[0150] or,

[0151] The attribute tagging unit 805 is used to tag the target attribute of the first source code of the first webpage according to the preset retention tagging rules before obtaining the first source code of the first webpage, so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attribute.

[0152] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 10 As shown:

[0153] The attribute adding unit 806 is used to add accessibility attributes to the tree nodes marked with target attributes after the node tree processing unit 803 filters out the tree nodes marked with target attributes in the first node tree and before the node tree processing unit 803 generates the second node tree based on the tree nodes marked with target attributes. The accessibility attributes enable the web page content corresponding to the tree node to be recognized.

[0154] In one implementation, the apparatus in this embodiment may further include the following units, such as... Figure 11 As shown:

[0155] The simplified monitoring unit 807 is used to monitor whether the webpage simplification conditions are met.

[0156] If the webpage simplification condition is met, the first source code acquisition unit 801 is triggered;

[0157] If the webpage simplification conditions are not met, the simplification monitoring unit 807 is triggered.

[0158] In one implementation, the conditions for webpage simplification include:

[0159] The current time of the first webpage reaches the preset target time;

[0160] Alternatively, the first duration reaches the preset target duration. The first duration begins to be recorded when the first webpage is first published and restarts recording after each trigger of the target unit, wherein the second source code obtains unit 804.

[0161] Alternatively, content that needs to be retained on the second page from the first page may be detected as having been changed;

[0162] Alternatively, a simplification trigger operation is received, wherein the simplification trigger operation is used to instruct the first webpage to be simplified.

[0163] In one implementation, the second source code acquisition unit 804 is specifically used to: traverse each tree node in the second node tree to obtain the node attributes and node type of each tree node in the second node tree;

[0164] Based on the node attributes and node type of the tree node, obtain the node code corresponding to each tree node in the second node tree;

[0165] Obtain the second source code based on the node codes corresponding to all tree nodes in the second node tree.

[0166] refer to Figure 12The diagram shown is a structural schematic of a webpage simplification electronic device provided in Embodiment 3 of this application. This electronic device is an electronic device with HTML webpage processing capabilities, such as a server. The technical solution in this embodiment is mainly used to solve the problem that existing technologies cannot efficiently simplify webpages.

[0167] The memory 1201 is used to store computer programs and data generated during the execution of computer programs;

[0168] The processor 1202 is configured to execute a computer program to: obtain the first source code of a first webpage; parse the first source code to obtain a first node tree corresponding to the first webpage; process the first node tree to obtain a second node tree; wherein the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree; and obtain the second source code based on the second node tree, wherein the second source code is used to obtain the second webpage.

[0169] Of course, electronic devices can also include other structures, such as communication modules and displays.

[0170] As can be seen from the above technical solution, in the webpage simplification electronic device provided in Embodiment 3 of this application, after parsing the first node tree corresponding to the first webpage through the first source code corresponding to the first webpage, the first node tree is processed to obtain a second node tree with a smaller number of tree nodes. Thus, a corresponding second webpage is obtained based on the second source code corresponding to the second node tree. Since the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree, the second webpage is simplified relative to the first webpage. Therefore, this application achieves the purpose of simplifying the webpage by reducing the number of tree nodes in the webpage's node tree.

[0171] Taking a system for generating simplified, accessible web pages from the original web page output in a web browser as an example, the technical solution in this embodiment marks the nodes to be retained in the original web page (i.e., the first web page mentioned above) according to certain rules (such as retaining nodes with specific node attributes); the HTML source code of the original web page is parsed and a DOM structure tree is generated; unmarked nodes in the DOM tree are pruned, and accessibility application attributes are added to the retained nodes according to the ARIA attribute table to form a complete DOM tree; a new simplified, accessible web page (i.e., the second web page mentioned above) is generated based on the tree structure of the complete DOM tree. The same method is used for each related functional page of the web page. Based on this, the entire process of generating simplified web pages can be completed independently by the generation server (which can be triggered periodically or manually when a new version of the original web page is released), without much involvement from technical personnel.

[0172] In summary, the system implemented based on the technical solution in this embodiment includes: a DOM parsing module, a node trimming module, a node mapping module, and a webpage generation module, such as... Figure 13 As shown in the image. This system can generate simplified web pages from the original web pages, as illustrated below. Figure 14 The flowchart shown illustrates the specific implementation scheme of the system.

[0173] First, in the original website source code, mark the nodes that need to be retained in the accessibility version (the nodes that need to be retained are determined by the developers based on the business requirements of the simplified version of the website; simply mark the nodes that need to be retained). (Nodes that do not need to be retained do not need to be marked again.)

[0174] For example, <div data-save=”true”>The `div` element is the node that needs to be preserved. The `data-save` attribute is just an example; this invention is not limited to this markup format (the markup format can be any custom attribute of an HTML element). The source code resides on a resource server.

[0175] Specifically, the functions of each software module in the system are as follows:

[0176] 1. DOM parsing module

[0177] This module employs browser-based webpage parsing technology and is divided into two sub-modules: a tag parser and a DOM tree builder. The tag parser uses a tokenization algorithm (which utilizes state machine principles; each state accepts one or more characters from the input stream and updates the next state based on these characters) to parse each tag. Once the tag parser has parsed the tags, the resulting HTML tags are sent to the DOM tree builder via programmatic calls to generate the DOM tree.

[0178] 2. Node Trimming Module

[0179] Using a breadth-first search algorithm, the DOM tree is traversed. For each node, all its attributes are retrieved, and the system checks if any node has an attribute marked for retention (e.g., the `data-save` attribute in the example above). Nodes marked for retention are then sent to the node mapping module for processing. The node mapping module adds the appropriate ARIA attribute to the nodes that need to be retained, based on the functionality described below. For example, if the original input box's label is... <input> After adding the ARIA attribute, it becomes <input aria-valuemin="0”aria-valuemax=100> (The added attribute indicates the maximum and minimum values ​​allowed for the input box), and the processed nodes are added to the new DOM tree (hereinafter referred to as the complete DOM tree); unmarked nodes are skipped directly, and the complete DOM tree does not perform any operations.

[0180] like Figure 3 As shown, the left side is the original DOM tree, and the right side is the DOM tree after pruning. The dashed lines in the original DOM tree represent nodes that need to be pruned and should not be displayed in the accessibility version. If a node is marked for deletion, it and all its child nodes will be pruned.

[0181] 3. Node Mapping Module

[0182] The node-attribute mapping table is a key-value data table that indicates which ARIA attributes a node should have added to make the node conform to the standards for accessible web applications.

[0183] The node mapping module takes the original website's webpage nodes as input, adds corresponding attributes to the nodes according to the node-attribute mapping table, and returns the nodes to the node trimming module.

[0184] 4. Webpage generation module

[0185] Breadth-first search traversals complete the DOM tree data structure. For each node visited, corresponding HTML node code is generated based on its attributes and node type. For example, if the visited node is a "button" with two attributes: an internal text attribute of "Submit" and an aria-button attribute of "Button", then the generated HTML node code would be:

[0186] <button aria-button="按钮”> submit< / button> After the traversal is complete, the HTML code of the webpage is finally generated.

[0187] Based on the above implementation scheme, the system can adopt a timed triggering mechanism (the timed triggering mechanism can be executed by the operating system's timed task, and the specific time interval depends on the frequency of system updates. For example, for systems with frequent updates, it can be set to trigger once a day during the off-peak hours of system access. If the system updates are not frequent, it can be adjusted appropriately) or be manually triggered after a new version of the original website system is launched, so as to ensure that the accessibility version of the website is consistent with the original website and updated synchronously.

[0188] Based on this, when a user selects a simplified control on a webpage, the user can access the simplified source code obtained by the system through a web browser. The web browser then translates the accessed source code into a browsable webpage, i.e., the simplified webpage, which the user can then view on the web browser.

[0189] As can be seen, the system implemented based on the technical solution in this embodiment can generate a corresponding DOM tree from the original webpage source code, and prune the DOM tree according to the node attribute representation of the original webpage, thereby generating a new simplified version of the website source code. Therefore, this system can automatically prune webpages to generate an accessibility version (or a more age-friendly version) without much manual intervention. Moreover, webpage upgrades can simultaneously trigger accessibility version upgrades without secondary development.

[0190] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0191] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0192] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0193] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for simplifying web pages, characterized in that, The method includes: Obtain the first source code of the first webpage; The first source code is parsed to obtain the first node tree corresponding to the first webpage; The first node tree is processed to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree. Based on the second node tree, the second source code is obtained, and the second source code is used to obtain the second webpage; The first node tree is processed to obtain the second node tree, including: Traverse the first node tree to obtain the node attributes corresponding to each tree node in the first node tree; Filter out the tree nodes in the first node tree that are marked with the target attribute; A second node tree is generated based on the tree node marked with the target attribute, wherein the target attribute is used to indicate that the web page content corresponding to the tree node it belongs to needs to be retained; The method further includes, after selecting tree nodes marked with the target attribute from the first node tree and before generating the second node tree based on the tree nodes marked with the target attribute: Accessibility attributes are added to the tree nodes marked with target attributes. These accessibility attributes enable the web page content corresponding to the tree node to be recognized by the web page's assistive devices. The assistive devices for the web page include a screen reading device, a screen magnifying device, and a voice control device. The screen reading device is used for visually impaired people to read the web page content, the screen magnifying device is used for visually impaired people to magnify the web page content, and the voice control device enables people with physical disabilities to operate the web page via voice. The tree node is marked with the target attribute in the following manner: Before obtaining the first source code of the first webpage, a marking input operation is received for the first source code; according to the marking input operation, the target attribute is marked on the first source code so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attribute; or, Before obtaining the first source code of the first webpage, the target attributes are marked on the first source code of the first webpage according to the preset retention marking rules, so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attributes.

2. The method according to claim 1, further comprising, before obtaining the first source code of the first webpage: Monitor whether the conditions for webpage simplification are met; If the webpage simplification conditions are met, then the following step is executed: obtain the first source code of the first webpage; If the webpage simplification conditions are not met, return to the previous step: monitor whether the webpage simplification conditions are met.

3. The method according to claim 2, characterized in that, The webpage simplification conditions include: The current time of the first webpage reaches the preset target time; or, The first duration reaches the preset target duration. The first duration starts recording when the first webpage is first published and restarts recording after each target step is executed. The target step is: to obtain the second source code according to the second node tree. or, The content that needs to be retained on the first webpage but is to be retained on the second webpage has been detected to have changed; or, A simplification trigger operation is received, which is used to instruct the first webpage to be simplified.

4. The method according to claim 1, characterized in that, Based on the second node tree, the second source code is obtained, including: Traverse each tree node in the second node tree to obtain the node attributes and node type of each tree node in the second node tree; Based on the node attributes and node type of the tree nodes, obtain the node code corresponding to each tree node in the second node tree; The second source code is obtained based on the node codes corresponding to all tree nodes in the second node tree.

5. A webpage simplification device, characterized in that, The device includes: The first source code acquisition unit is used to obtain the first source code of the first webpage. The first source code parsing unit is used to parse the first source code to obtain the first node tree corresponding to the first webpage; A node tree processing unit is used to process the first node tree to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree. The second source code acquisition unit is used to obtain the second source code based on the second node tree, and the second source code is used to obtain the second webpage; The node tree processing unit is used to process the first node tree to obtain a second node tree, including: traversing the first node tree to obtain the node attributes corresponding to each tree node in the first node tree; filtering out the tree nodes in the first node tree marked with target attributes; and generating a second node tree based on the tree nodes marked with target attributes, wherein the target attributes are used to indicate that the web page content corresponding to the tree node where it is located needs to be retained. The process includes, after selecting tree nodes marked with the target attribute from the first node tree, and before generating the second node tree based on the tree nodes marked with the target attribute, the following steps are also included: Accessibility attributes are added to the tree nodes marked with target attributes. These accessibility attributes enable the web page content corresponding to the tree node to be recognized by the web page's assistive devices. The assistive devices for the web page include a screen reading device, a screen magnifying device, and a voice control device. The screen reading device is used for visually impaired people to read the web page content, the screen magnifying device is used for visually impaired people to magnify the web page content, and the voice control device enables people with physical disabilities to operate the web page via voice. The tree node is marked with the target attribute in the following manner: Before obtaining the first source code of the first webpage, a marking input operation is received for the first source code; according to the marking input operation, the target attribute is marked on the first source code so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attribute; or, Before obtaining the first source code of the first webpage, the target attributes are marked on the first source code of the first webpage according to the preset retention marking rules, so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attributes.

6. An electronic device, characterized in that, The device includes: A memory used to store computer programs and the data generated by the execution of said computer programs; A processor is configured to execute the computer program to: obtain a first source code of a first webpage; parse the first source code to obtain a first node tree corresponding to the first webpage; process the first node tree to obtain a second node tree; the number of tree nodes in the second node tree is less than the number of tree nodes in the first node tree; and obtain a second source code based on the second node tree, wherein the second source code is used to obtain a second webpage. The first node tree is processed to obtain the second node tree, including: Traverse the first node tree to obtain the node attributes corresponding to each tree node in the first node tree; Filter out the tree nodes in the first node tree that are marked with the target attribute; A second node tree is generated based on the tree node marked with the target attribute, wherein the target attribute is used to indicate that the web page content corresponding to the tree node it belongs to needs to be retained; The process includes, after selecting tree nodes marked with the target attribute from the first node tree, and before generating the second node tree based on the tree nodes marked with the target attribute, the following steps are also included: Accessibility attributes are added to the tree nodes marked with target attributes. These accessibility attributes enable the web page content corresponding to the tree node to be recognized by the web page's assistive devices. The assistive devices for the web page include a screen reading device, a screen magnifying device, and a voice control device. The screen reading device is used for visually impaired people to read the web page content, the screen magnifying device is used for visually impaired people to magnify the web page content, and the voice control device enables people with physical disabilities to operate the web page via voice. The tree node is marked with the target attribute in the following manner: Before obtaining the first source code of the first webpage, a marking input operation is received for the first source code; according to the marking input operation, the target attribute is marked on the first source code so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attribute; or, Before obtaining the first source code of the first webpage, the target attributes are marked on the first source code of the first webpage according to the preset retention marking rules, so that the tree nodes of the first node tree corresponding to the first webpage are marked with the target attributes.

Citation Information

Patent Citations

  • Webpage content reconstruction method and system

    CN106528068A