A method and apparatus for taking screenshots of web pages

By processing DOM nodes and image streams, image selection in any area of ​​a browser page is enabled, solving the problem of cumbersome user operations in existing technologies and improving user experience.

CN115994009BActive Publication Date: 2026-11-17DINGDAO ZHILIAN (BEIJING) TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211366871.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-01
Publication Date
2026-11-17
Estimated Expiration
2042-11-01

AI Technical Summary

Technical Problem

In existing technologies, users need to perform multiple steps when selecting images on a browser page, resulting in a poor user experience and affecting the normal use of other operations.

Method used

By creating a first Dom node and a second Dom node, using the node attributes of the Dom nodes to represent the positional attributes of the region bounding box, a first image stream and a second image stream are generated, and background localization processing is performed to obtain a composite structure to represent the region bounding box, thereby achieving image selection.

Benefits of technology

The browser page allows for image selection within any area, reducing user operations without affecting other operations and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115994009B_ABST
    Figure CN115994009B_ABST
Patent Text Reader

Abstract

This invention discloses a method and apparatus for taking screenshots of web pages, relating to the field of computer applications. The method includes: creating a first DOM node when a user selects a region within a webpage; determining the extent of the region and generating a first image stream from the webpage; creating a second DOM node based on the node attributes of the first DOM node; using the first coordinates of the region, performing background positioning processing on the first image stream and the second DOM node to obtain a composite structure, which includes a first image stream that is set to hidden and a second DOM node that is set to currently be displayed; and generating a second image stream from the currently displayed second DOM node on the composite structure, the second image stream being used to represent the region. This invention enables image selection within any area of ​​a browser page, filling a gap in the prior art; simultaneously, it reduces user operations and improves user experience during image selection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer applications, and more particularly to a method and apparatus for taking screenshots of web pages. Background Technology

[0002] Currently, users typically select images using their mobile devices. Most mobile devices support image selection, such as using pre-installed software (Windows screenshot tool, Snipaste screenshot tool), or mobile apps (WeChat screenshot function), allowing users to freely select images.

[0003] In practical applications, users may also want to freely select a specific area of ​​an image within a browser page, similar to copying text within a browser page. Typically, users can use screenshot software or apps pre-installed on their devices to select images within the browser page.

[0004] However, in the above implementation, users need to perform other operations (e.g., open third-party software or applications, and then select, copy, save as, etc.) before they can select images on the browser page. Furthermore, during the image selection process, other operations currently enabled on the terminal device are unavailable until the selection process is complete. These drawbacks result in significant inconvenience for users and a poor user experience. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a page screenshot method and apparatus, which enables image selection in any area of ​​an existing browser page, filling the gap in the prior art; at the same time, during the image selection process, user operations are reduced and the status of other operations that are already in progress is not affected, thereby improving the user experience.

[0006] In a first aspect, embodiments of the present invention provide a method for taking a screenshot of a webpage, the method being applied to an electronic device, the electronic device opening and displaying a webpage, the method comprising:

[0007] When a user selects a region box within the webpage, a first DOM node is created so that the node attributes of the first DOM node represent the position attributes of the region box.

[0008] Determine the extent of the region frame and generate the webpage as a first image stream;

[0009] Based on the node attributes of the first DOM node, create a second DOM node such that the node attributes of the second DOM node are the same as those of the first DOM node.

[0010] Using the first coordinates of the region box, background positioning processing is performed on the first image stream and the second DOM node to obtain a composite structure. The composite structure includes the first image stream that is set to be hidden and the second DOM node that is set to be currently displayed.

[0011] On the composite structure, the currently displayed second DOM node is generated as a second image stream, which is used to represent the region bounding box.

[0012] Secondly, embodiments of the present invention provide a page screenshot device, the device being applied to an electronic device that opens and displays a webpage, the device comprising:

[0013] The first creation unit is used to create a first DOM node when a user selects a region box within the webpage, so that the node attributes of the first DOM node represent the position attributes of the region box.

[0014] The first generation unit is used to determine the range of the region box and generate the webpage as a first image stream;

[0015] The second creation unit is used to create a second DOM node based on the node attributes of the first DOM node, so that the node attributes of the second DOM node are the same as those of the first DOM node.

[0016] The processing unit is used to perform background positioning processing on the first image stream and the second DOM node using the first coordinates of the region box to obtain a composite structure, the composite structure including the first image stream which is set to be hidden and the second DOM node which is set to be currently displayed;

[0017] The second generation unit is used to generate a second image stream from the currently displayed second DOM node on the composite structure, the second image stream being used to represent the region box.

[0018] Thirdly, embodiments of the present invention provide an electronic device, the electronic device comprising: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is disposed within the space enclosed by the housing, and the processor and the memory are disposed on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the page screenshot method described in the first aspect above.

[0019] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the page screenshot method described in the first aspect.

[0020] This invention provides a page screenshot method and apparatus. When a user selects a region box within a webpage, the electronic device creates a first DOM node, such that the node attributes of the first DOM node represent the positional attributes of the region box. The electronic device determines the extent of the region box and generates a first image stream from the webpage. Based on the node attributes of the first DOM node, the electronic device creates a second DOM node, such that the node attributes of the second DOM node are the same as those of the first DOM node. Using the first coordinates of the region box, the electronic device performs background positioning processing on the first image stream and the second DOM node to obtain a composite structure. This composite structure includes a first image stream that is set to be hidden and a second DOM node that is set to be currently displayed. On the composite structure, the electronic device generates a second image stream from the currently displayed second DOM node, which is used to represent the region box.

[0021] The aforementioned solution enables image selection within any area of ​​a browser page, filling a gap in existing technology. At the same time, it reduces user operations during image selection and does not affect the status of other ongoing operations, thus improving the user experience. Attached Figure Description

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

[0023] Figure 1 A flowchart of a page screenshot method provided in an embodiment of the present invention;

[0024] Figure 2 Flowchart of another page screenshot method provided in an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram of a page and a selected area bounding box provided in an embodiment of the present invention;

[0026] Figure 4 A schematic diagram of the composite structure provided in an embodiment of the present invention;

[0027] Figure 5 This is a schematic diagram of the device structure for the page screenshot method provided in an embodiment of the present invention;

[0028] Figure 6 This is a schematic diagram of an electronic device structure provided in an embodiment of the present invention. Detailed Implementation

[0029] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0030] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0031] The following is in conjunction with the appendix Figure 1 The solution provided by the embodiments of the present invention will be described in detail. Figure 1 This is a flowchart illustrating a page screenshot method provided in an embodiment of the present invention. In this embodiment, the implementing entity is an electronic device. This electronic device can be a terminal device, a server with a display device, etc., and the terminal device can specifically include a PC, desktop computer, tablet computer, etc. Figure 1 As shown, the method in this embodiment specifically includes the following steps: Figure 1 As shown, the method in this embodiment specifically includes the following steps:

[0032] Step 110: When the user selects a region box within the webpage, a first DOM node is created so that the node attributes of the first DOM node represent the position attributes of the region box.

[0033] In this step, the electronic device displays a desktop to the user, which includes multiple application (app) icons. When the user wants to access or view relevant content from the network, the user inputs an open command into the electronic device using an input device (e.g., a mouse). This open command is the user selecting and double-clicking an application icon (e.g., the first application icon).

[0034] Upon receiving the input command, the electronic device opens and displays the webpage corresponding to the first application icon selected by the user. Understandably, this webpage can include text, images, and other content.

[0035] After an electronic device displays a webpage to a user, the user browses the webpage and selects the content they need. Users can select content within a defined area on the webpage. This selected content includes, but is not limited to, text and images.

[0036] When a user selects a region within a webpage, the electronic device creates a first Document Object Model (DOM) node. This first DOM node includes node properties, which characterize the position of the region. The DOM node is a standard programming interface recommended by the W3C for processing Extensible Markup Language (EXPLAIN).

[0037] The aforementioned node attributes specifically include the width and height attributes of the first Dom node, and the positional attributes specifically include the width and height attributes of the region box. The width attribute of the first Dom node is used to characterize the width of the region box, and the height attribute of the first Dom node is used to characterize the height of the region box. This allows the electronic device to reflect changes in the region box's extent by utilizing the changing width and height attributes of the first Dom node.

[0038] In this embodiment of the invention, the first Dom node can be abstractly understood as an empty box, the size of which represents the range of the region box.

[0039] In subsequent embodiments, the location attributes of the region box selected by the user within the webpage and the node attributes of the first DOM node will be described in detail, and will not be repeated here.

[0040] Step 120: Determine the range of the region box and generate the webpage as a first image stream.

[0041] In this step, after the electronic device creates the first DOM node, it determines the range of the region selected by the user, and at the same time, it generates the webpage as the first image stream.

[0042] The first image stream is specifically in base64 format, a recognizable image format typically represented as a binary string image address. This string includes English letters and numbers. For example: wednlgpmc79213688.

[0043] It should be noted that electronic devices can use third-party plugins to generate the first image stream from a webpage, such as the "html2canvas" plugin. The process of third-party plugins generating the first image stream from a webpage can be referenced from existing generation methods and will not be elaborated here.

[0044] In subsequent embodiments, the process of determining the area box selected by the user within the webpage will be described in detail, and will not be repeated here.

[0045] Step 130: Create a second DOM node based on the node attributes of the first DOM node, so that the node attributes of the second DOM node are the same as those of the first DOM node.

[0046] In this step, after the electronic device generates the first image stream from the webpage, the electronic device creates the second DOM node.

[0047] It's understandable that the second DOM node can be abstractly understood as an empty box, and its node attributes include width and height. The width of the second DOM node is the same as that of the first DOM node, and the height of the second DOM node is the same as that of the first DOM node. Thus, the second DOM node can indirectly define the bounding box selected by the user.

[0048] Step 140: Using the first coordinates of the region box, perform background positioning processing on the first image stream and the second DOM node to obtain a composite structure. The composite structure includes the first image stream that is set to be hidden and the second DOM node that is set to be currently displayed.

[0049] In this step, after the electronic device creates the second DOM node, it obtains the first coordinates of the bounding box. Using these first coordinates, the electronic device performs background positioning processing on the first image stream and the second DOM node, resulting in a composite structure. The composite structure includes the first image stream, which is set to be hidden, and the second DOM node, which is set to be currently displayed.

[0050] In other words, during the background positioning process, the electronic device uses the first image stream as the background of the second DOM node. Simultaneously, the first image stream is hidden, while the second DOM node is currently displayed. This highlights the second DOM node, effectively highlighting the area selected by the user.

[0051] In subsequent embodiments, the process of using the first coordinates of the region box to perform background positioning processing on the first image stream and the second DOM node to obtain the composite structure will be described in detail, and will not be repeated here.

[0052] Step 150: On the composite structure, the currently displayed second DOM node is generated as a second image stream, which is used to represent the region bounding box.

[0053] In this step, after the electronic device obtains the composite structure, it generates a second image stream from the currently displayed second DOM node on the composite structure. This second image stream can be used to represent the bounding box selected by the user on the webpage.

[0054] The second image stream is specifically in base64 format, a recognizable image format that is typically a binary string representing the image address. This string includes English letters and numbers.

[0055] It should be noted that electronic devices can also generate a second image stream from the second DOM using third-party plugins, such as the "html2canvas" plugin. The process of generating a second image stream from the second DOM using third-party plugins can be found in existing methods and will not be elaborated upon here.

[0056] It should be noted that the above steps can be implemented using program code. Electronic devices can encapsulate the program code as an independent component module and load this component module into the front-end project code. In this way, image selection can be easily and conveniently implemented in any area of ​​the browser page, filling a gap in existing technology. At the same time, during the image selection process, user operations are reduced and the status of other ongoing operations is not affected, thus improving the user experience.

[0057] In one example, the component module is... <lu-select-area>Starting with <lu-select-area>This is the end. Users can freely select any content on the webpage described between the beginning and the end, whether it's text or images, using their input device.

[0058] The following is in conjunction with the appendix Figure 2 Appendix Figure 3 and appendix Figure 4 The solution provided by the embodiments of the present invention will be described in detail. Figure 2 A flowchart of another page screenshot method provided in an embodiment of the present invention. Figure 3 This is a schematic diagram of a page and a selected area bounding box provided for an embodiment of the present invention. Figure 4 This is a schematic diagram of the composite structure provided in an embodiment of the present invention.

[0059] Electronic devices display a desktop to the user, which includes multiple application (app) icons. When a user wants to access or view content from the internet, they input a command into the electronic device. This command is typically an action where the user selects and double-clicks an application icon (e.g., the first application icon).

[0060] Upon receiving the input command, the electronic device opens and displays the webpage corresponding to the first application icon selected by the user. Understandably, this webpage can include text, images, and other content.

[0061] After the electronic device displays a webpage to the user, the user browses the webpage and selects the content they need. The process is as follows:

[0062] Step 210: When the user selects a region box within the webpage, a first DOM node is created so that the node attributes of the first DOM node represent the position attributes of the region box.

[0063] In this step, after the electronic device displays a webpage to the user, it receives a click instruction input by the user on the webpage. This click instruction is an operation in which the user clicks any location on the page using an input device (e.g., a mouse).

[0064] Based on the click instruction, the clicking device determines the click position and records the first coordinates corresponding to the click position (specifically (x1, y1)). The first coordinates are the starting position of the area box selected by the user.

[0065] In this embodiment of the invention, after an electronic device records the first coordinates, the electronic device creates a first Dom node and positions the first Dom node at the first coordinates.

[0066] The electronic device receives drag-and-drop instructions entered by the user on a webpage. These instructions are generated by the user clicking and sliding on the input device.

[0067] The first DOM node created by the electronic device includes node attributes, which characterize the positional attributes of the region bounding box. Specifically, the node attributes include the width and height attributes of the first DOM node, and the positional attributes include the width and height attributes of the region bounding box. The width attribute of the first DOM node characterizes the width of the region bounding box, and the height attribute of the first DOM node characterizes the height of the region bounding box.

[0068] It is understandable that the combination of the click and drag commands described above represents the process of a user selecting a region box within a webpage. The extent of the region box changes according to the user's swipe operation. Since the first DOM node is positioned at the first coordinate, and the node attributes of the first DOM node represent the positional attributes of the region box, the width and height attributes of the first DOM node also change with the user's swipe operation after the electronic device receives the swipe operation, thereby causing the extent of the region box to change accordingly.

[0069] Step 220: Determine the range of the region box and generate the webpage as a first image stream.

[0070] In this step, after the electronic device creates the first DOM node, it first determines the range of the region box selected by the user.

[0071] As described in step 210, the user inputs click and drag commands into the electronic device via an input device. The electronic device determines the click location based on the click command and records the first coordinate corresponding to the click location. This first coordinate is the starting position of the bounding box. Based on the drag command, the electronic device calculates the drag distance, including both horizontal and vertical drag distances, starting from the first coordinate. The electronic device binds the horizontal drag distance to the width attribute of the first DOM node and the vertical drag distance to the height attribute of the first DOM node.

[0072] The user inputs a release command into the electronic device via an input device. This release command is the same as the previously mentioned click command, i.e., the action of lifting a click. Based on the release command, the electronic device determines the release position entered by the user and records the corresponding second coordinates (specifically (x2, y2)). These second coordinates represent the ending position of the area bounding box selected by the user.

[0073] The electronic device uses the horizontal drag distance between the release position and the click position as the width attribute of the first DOM node. The electronic device uses the vertical drag distance between the release position and the click position as the height attribute of the first DOM node. Using the first coordinate, the second coordinate, the width attribute, and the height attribute, the electronic device defines the bounding box.

[0074] Specifically, the electronic device uses the difference between the second coordinate x2 and the first coordinate x1 (this difference represents the horizontal drag distance of the region box) as the width attribute of the first DOM node. The electronic device uses the difference between the second coordinate y2 and the first coordinate y1 (this difference represents the vertical drag distance of the region box) as the height attribute of the first DOM node. Thus, using the first coordinate, the second coordinate, the width attribute, and the height attribute of the first DOM node, the electronic device determines the extent of the region box.

[0075] like Figure 3 As shown, the dashed box represents the region selected by the user. The top-left vertex of this region is the first coordinate, which is the click position entered by the user; the bottom-right vertex of this region is the second coordinate, which is the release position entered by the user. The longer side of the region is the width attribute of the first DOM node, and the shorter side of the region is the height attribute of the first DOM node.

[0076] Optionally, after inputting the release command, the user can further adjust the area bounding box as needed. In this case, the user inputs an adjustment command into the electronic device, which can be a combination of a click command and a drag command. That is, the user first inputs a click command to determine the adjustment position. Typically, this adjustment position coincides with the release position. Then, the user inputs a drag command to change the area bounding box's range. Finally, the user inputs the release command to end the adjustment process, forming the final area bounding box.

[0077] Understandably, when a user initially selects a region or subsequently adjusts the region, the electronic device compares the difference between the current coordinates and the first coordinate with 0. If the difference is greater than 0, the distance represented by the difference is increased to the right or downward from the first coordinate; if the difference is less than 0, the distance represented by the difference is increased to the left or upward from the first coordinate.

[0078] For example, the electronic device determines whether the difference between the current coordinate x' and the first coordinate x1 is greater than 0. If it is, it increases the distance represented by the difference horizontally to the right, starting from x1; otherwise, it increases the distance represented by the difference to the left. Whether increasing the distance to the left or right, it cannot exceed the leftmost or rightmost horizontal coordinate point of the page border. The electronic device also determines whether the difference between the current coordinate y' and the first coordinate y1 is greater than 0. If it is, it increases the distance represented by the difference horizontally downwards, starting from y1; otherwise, it increases the distance represented by the difference upwards. Whether increasing the distance upwards or downwards, it cannot exceed the topmost or bottommost vertical coordinate point of the page border.

[0079] While the electronic device determines the extent of the region (that is, while the electronic device receives the release command input by the user), the electronic device generates the webpage as the first image stream.

[0080] Step 230: Create a second DOM node based on the node attributes of the first DOM node, so that the node attributes of the second DOM node are the same as those of the first DOM node.

[0081] In this step, after the electronic device generates the first image stream from the webpage, the electronic device creates the second DOM node.

[0082] Optionally, the electronic device binds the width attribute of the first DOM node to the width attribute of the second DOM node, and binds the height attribute of the first DOM node to the height attribute of the second DOM node.

[0083] Step 240: Using the first coordinates of the region box, perform background positioning processing on the first image stream and the second DOM node to obtain a composite structure. The composite structure includes the first image stream that is set to be hidden and the second DOM node that is set to be currently displayed.

[0084] In this step, after the electronic device creates the second DOM node, it again retrieves the first coordinates of the previously recorded region bounding box. The electronic device determines the position of these first coordinates within the first image stream. It then aligns the top-left vertex of the region enclosed by the width and height attributes of the second DOM node with this position, and vertically positions the enclosed region above the first image stream, resulting in a composite structure. The electronic device configures this enclosed region as currently displayed and configures the first image stream as hidden.

[0085] like Figure 4 As shown, the dashed box represents the area enclosed by the width and height attributes of the second DOM node. The top-left vertex of this enclosed area coincides with the position of the first DOM node in the first image stream. The first image stream serves as the background and is located below, while the second DOM node is above it. The dotted line indicates that the first image stream is hidden.

[0086] Step 250: On the composite structure, the currently displayed second DOM node is generated as a second image stream, which is used to represent the region bounding box.

[0087] In this step, after the electronic device obtains the composite structure, it generates a second image stream from the currently displayed second DOM node on the composite structure. This second image stream can be used to represent the bounding box selected by the user on the webpage.

[0088] Step 260: Based on the region display instruction input by the user, create an image tag node, the address of which is the second image stream.

[0089] In this step, after the electronic device generates the second image stream, it can display or not display the images represented by the second image stream to the user according to different needs.

[0090] In one implementation, to view content selected from a webpage, the user can input a region display command into the electronic device. Upon receiving the command, the electronic device creates an image tag node, such as an `Img` tag node. This `Img` tag node includes a `src` attribute, within which the electronic device stores a second image stream; in other words, the electronic device uses this second image stream as the address of the image tag node. Thus, the user can view the selected content through the `Img` tag node.

[0091] In another implementation, where the content selected by the user from the webpage is for subsequent AI analysis, filtering, or image processing, the user no longer needs to view the selected content. In this case, the electronic device directly transmits a second image stream to the backend. The backend then uses this second image stream to obtain the image selected by the user.

[0092] Step 270: Display the image tag node to the user so that the user can view the corresponding image within the region box through the second image stream.

[0093] In this step, after the electronic device creates the image tag node, it displays the image tag node to the user so that the user can view the corresponding image within the area box through the second image stream.

[0094] Optionally, in this embodiment, the user can also configure the region box attributes. Under normal configuration, after a user completes a region box selection operation, the region box is no longer currently displayed. That is, after the user selects a region box, the region box is hidden and no longer shown to the user. In this case, the display attribute value of the region box is false.

[0095] If a user wants to keep the selected area box displayed and not make it disappear under any circumstances after completing a selection operation, the user should input an area box attribute configuration instruction into the electronic device before performing the steps in this embodiment. The area box attribute configuration instruction includes display attributes.

[0096] After receiving the region box attribute configuration instruction, the electronic device retrieves the display attributes from it. The electronic device identifies the value of the display attributes; if the value is true, the electronic device configures the region box to be constantly displayed. Specifically, constant display means displaying the region box in a color that is clearly different from the first image stream, that is, the color difference between the region box and the first image stream exceeds a preset color difference threshold. For example, in one example, if the current color of the first image stream is yellow, then the current displayed color of the region box could be blue.

[0097] Optionally, in this embodiment of the invention, the image stream is all div tags. In practical applications, any block-level tag in the HTML language can also be used, such as the p tag, etc.

[0098] Figure 5 This is a schematic diagram of a page screenshot device provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the page screenshot device of this embodiment may include: a first creation unit 510, a first generation unit 520, a second creation unit 530, a processing unit 540, and a second generation unit 550.

[0099] The first creation unit 510 is used to create a first DOM node when the user selects a region box within the webpage, so that the node attributes of the first DOM node represent the position attributes of the region box.

[0100] The first generation unit 520 is used to determine the range of the region box and generate the webpage as a first image stream;

[0101] The second creation unit 530 is used to create a second DOM node based on the node attributes of the first DOM node, so that the node attributes of the second DOM node are the same as those of the first DOM node.

[0102] The processing unit 540 is used to perform background positioning processing on the first image stream and the second DOM node using the first coordinates of the region box to obtain a composite structure. The composite structure includes the first image stream that is set to be hidden and the second DOM node that is set to be currently displayed.

[0103] The second generation unit 550 is used to generate a second image stream from the currently displayed second DOM node on the composite structure, the second image stream being used to represent the region bounding box.

[0104] Optionally, the first generation unit 520 is specifically used to determine the click position according to the click instruction entered by the user in the webpage, and record the first coordinates corresponding to the click position, wherein the first coordinates are the starting position of the region box;

[0105] Based on the drag command input by the user on the webpage, the drag distance is calculated with the first coordinate as the starting point. The drag distance includes the horizontal drag distance and the vertical drag distance.

[0106] Bind the horizontal drag distance to the width attribute of the first DOM node, and bind the vertical drag distance to the height attribute of the first DOM node;

[0107] Based on the release command entered by the user on the webpage, the release position is determined and the second coordinate corresponding to the release position is recorded. The second coordinate is the end position of the region box.

[0108] The horizontal drag distance between the release position and the click position is used as the width attribute of the first DOM node, and the vertical drag distance between the release position and the click position is used as the height attribute of the first DOM node;

[0109] The extent of the region box is determined using the first coordinate, the second coordinate, the width attribute, and the height attribute.

[0110] Optionally, the second creation unit 530 is specifically used to bind the width attribute of the first DOM node to the width attribute of the second DOM node, and to bind the height attribute of the first DOM node to the height attribute of the second DOM node.

[0111] Optionally, the node attributes include width and height attributes;

[0112] The processing unit 540 is specifically used to determine the position of the first coordinates in the first image stream;

[0113] The top left vertex of the region enclosed by the width and height attributes of the second Dom node is aligned with the position, and the enclosed region is placed vertically above the first image stream to obtain a composite structure.

[0114] Configure the enclosed area as the currently displayed area, and configure the first image stream as a hidden display.

[0115] Optionally, the device further includes: a third creation unit (not shown in the figure) and a display unit (not shown in the figure);

[0116] The third creation unit is used to create an image tag node according to the area display instruction input by the user, wherein the address of the image tag node is the second image stream;

[0117] The display unit is used to display the image tag node to the user, so that the user can view the corresponding image within the region box through the second image stream.

[0118] Optionally, the device further includes: a receiving unit (not shown in the figure) and a configuration unit (not shown in the figure);

[0119] The receiving unit is configured to receive a region box attribute configuration instruction input by the user, the region box attribute configuration instruction including display attributes;

[0120] The configuration unit is configured to configure the region box to be constantly displayed if the value of the display attribute is true.

[0121] The apparatus of this embodiment can be used to perform Figures 1-3 The technical solutions of the method embodiments shown are similar in principle and in effect, and will not be described again here.

[0122] Accordingly, the page screenshot device provided in this embodiment of the invention can also be implemented using another structure. Figure 6 This is a schematic diagram of an embodiment of an electronic device provided by the present invention, which can realize the present invention. Figures 1-3 The process of the illustrated embodiment is as follows: Figure 6 As shown, the above-mentioned electronic device may include: a housing 61, a processor 62, a memory 63, a circuit board 64, and a power supply circuit 65, wherein the circuit board 64 is disposed inside the space enclosed by the housing 61, and the processor 62 and the memory 63 are disposed on the circuit board 64; the power supply circuit 65 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 63 is used to store executable program code; the processor 62 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 63, for executing the methods described in the foregoing embodiments.

[0123] For details on the specific execution process of the above steps by processor 62, and the steps further executed by processor 62 through running executable program code, please refer to the present invention. Figures 1-3 The description of the illustrated embodiments will not be repeated here.

[0124] The electronic device is a device that provides computing services. It consists of a processor, hard drive, memory, system bus, etc. The electronic device is similar to the general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0125] It should be noted that, in this document, terms such as "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0126] The various embodiments in this specification are described in a related manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0127] In particular, the device embodiment is basically similar to the method embodiment, so the description is relatively simple. For relevant details, please refer to the description of the method embodiment.

[0128] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0129] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0130] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof.

[0131] In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0132] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0133] For ease of description, the above apparatus is described by dividing it into various functional units / modules. Of course, in implementing this invention, the functions of each unit / module can be implemented in one or more software and / or hardware.

[0134] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of the present invention.

Claims

1. A method of taking a screenshot of a page, characterized in that, The method is applied to an electronic device that opens and displays a webpage, and the method includes: When a user selects a region box within the webpage, a first DOM node is created so that the node attributes of the first DOM node represent the position attributes of the region box. Determine the extent of the region frame and generate the webpage as a first image stream; Based on the node attributes of the first DOM node, create a second DOM node such that the node attributes of the second DOM node are the same as those of the first DOM node. Using the first coordinates of the region box, background positioning processing is performed on the first image stream and the second DOM node to obtain a composite structure. The composite structure includes the first image stream that is set to be hidden and the second DOM node that is set to be currently displayed; the first image stream serves as the background of the second DOM node. On the composite structure, the currently displayed second DOM node is generated as a second image stream, which is used to represent the region bounding box.

2. The method according to claim 1, characterized in that, Determining the extent of the region bounding box specifically includes: Based on the click command entered by the user on the webpage, the click position is determined and the first coordinate corresponding to the click position is recorded. The first coordinate is the starting position of the region box. Based on the drag command input by the user on the webpage, the drag distance is calculated with the first coordinate as the starting point. The drag distance includes the horizontal drag distance and the vertical drag distance. Bind the horizontal drag distance to the width attribute of the first DOM node, and bind the vertical drag distance to the height attribute of the first DOM node; Based on the release command entered by the user on the webpage, the release position is determined and the second coordinate corresponding to the release position is recorded. The second coordinate is the end position of the region box. The horizontal drag distance between the release position and the click position is used as the width attribute of the first DOM node, and the vertical drag distance between the release position and the click position is used as the height attribute of the first DOM node; The extent of the region box is determined using the first coordinate, the second coordinate, the width attribute, and the height attribute.

3. The method according to claim 2, characterized in that, The step of creating a second DOM node based on the node attributes of the first DOM node specifically includes: Bind the width attribute of the first DOM node to the width attribute of the second DOM node, and bind the height attribute of the first DOM node to the height attribute of the second DOM node.

4. The method according to claim 1, characterized in that, The node attributes include width and height. The step of using the first coordinates of the region bounding box to perform background localization processing on the first image stream and the second DOM node to obtain a composite structure specifically includes: Determine the position of the first coordinate in the first image stream; The top left vertex of the region enclosed by the width and height attributes of the second Dom node is aligned with the position, and the enclosed region is placed vertically above the first image stream to obtain a composite structure. Configure the enclosed area as the currently displayed area, and configure the first image stream as a hidden display.

5. The method according to claim 1, characterized in that, The method further includes: Based on the user-inputted area display instruction, an image tag node is created, and the address of the image tag node is the second image stream; The image tag node is displayed to the user so that the user can view the corresponding image within the region box through the second image stream.

6. The method according to claim 1, characterized in that, The method further includes: Receive a region box attribute configuration instruction input by the user, the region box attribute configuration instruction including display attributes; If the value of the display attribute is true, then the region box is configured to be displayed constantly.

7. A page screenshot device, characterized in that, The device is used in an electronic device that opens and displays a webpage, and the device includes: The first creation unit is used to create a first DOM node when a user selects a region box within the webpage, so that the node attributes of the first DOM node represent the position attributes of the region box. The first generation unit is used to determine the range of the region box and generate the webpage as a first image stream; The second creation unit is used to create a second DOM node based on the node attributes of the first DOM node, so that the node attributes of the second DOM node are the same as those of the first DOM node. The processing unit is configured to use the first coordinates of the region box to perform background positioning processing on the first image stream and the second DOM node to obtain a composite structure. The composite structure includes the first image stream which is set to be hidden and the second DOM node which is set to be currently displayed; the first image stream serves as the background of the second DOM node. The second generation unit is used to generate a second image stream from the currently displayed second DOM node on the composite structure, the second image stream being used to represent the region box.

8. The apparatus according to claim 7, characterized in that, The first generation unit is specifically used to determine the click position according to the click instruction entered by the user on the webpage, and record the first coordinate corresponding to the click position, wherein the first coordinate is the starting position of the region box; Based on the drag command input by the user on the webpage, the drag distance is calculated with the first coordinate as the starting point. The drag distance includes the horizontal drag distance and the vertical drag distance. Bind the horizontal drag distance to the width attribute of the first DOM node, and bind the vertical drag distance to the height attribute of the first DOM node; Based on the release command entered by the user on the webpage, the release position is determined and the second coordinate corresponding to the release position is recorded. The second coordinate is the end position of the region box. The horizontal drag distance between the release position and the click position is used as the width attribute of the first DOM node, and the vertical drag distance between the release position and the click position is used as the height attribute of the first DOM node; The extent of the region box is determined using the first coordinate, the second coordinate, the width attribute, and the height attribute.

9. The apparatus according to claim 8, characterized in that, The second creation unit is specifically used to bind the width attribute of the first DOM node to the width attribute of the second DOM node, and to bind the height attribute of the first DOM node to the height attribute of the second DOM node.

10. The apparatus according to claim 7, characterized in that, The node attributes include width and height. The processing unit is specifically used to determine the position of the first coordinates in the first image stream; The top left vertex of the region enclosed by the width and height attributes of the second Dom node is aligned with the position, and the enclosed region is placed vertically above the first image stream to obtain a composite structure. Configure the enclosed area as the currently displayed area, and configure the first image stream as a hidden display.

11. The apparatus according to claim 7, characterized in that, The device further includes: a third creation unit and a display unit; The third creation unit is used to create an image tag node according to the area display instruction input by the user, wherein the address of the image tag node is the second image stream; The display unit is used to display the image tag node to the user, so that the user can view the corresponding image within the region box through the second image stream.

12. The apparatus according to claim 7, characterized in that, The device further includes: a receiving unit and a configuration unit; The receiving unit is configured to receive a region box attribute configuration instruction input by the user, the region box attribute configuration instruction including display attributes; The configuration unit is configured to configure the region box to be constantly displayed if the value of the display attribute is true.

13. An electronic device, characterized in that, The electronic device includes: a housing, a processor, a memory, a circuit board, and a power supply circuit, wherein the circuit board is disposed inside the space enclosed by the housing, and the processor and the memory are disposed on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the page screenshot method described in any of claims 1-6.

14. A computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the page screenshot method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Webpage screenshot method and webpage screenshot device

    CN113744363A