Method, system and storage medium for preventing webpage text from being copied

By real-time monitoring and recovery of CSS attributes combined with the difference algorithm, users and crawlers prevent copying web page texts, solving the problem of user and crawlers in the prior art, and realizing the security protection of web page texts.

CN116821544BActive Publication Date: 2025-08-08东风悦享科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310606319.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-26
Publication Date
2025-08-08
Estimated Expiration
2043-05-26

AI Technical Summary

Technical Problem

The prior art cannot effectively prevent users from copying web page text through browser developer tools, and crawlers can directly crawl the web page source code to copy text content, which cannot protect user rights and text security.

Method used

Get the DOM node data information of web page text in real time, monitor changes in CSS attributes, restore CSS attributes through the background, combine the difference algorithm to determine whether the user opens the console to copy text, and deletes text information when necessary to prevent crawlers from crawling.

Benefits of technology

Effectively prevent users from changing DOM properties on the console to copy text, protect user rights, and at the same time prevent crawlers from crawling web page source code copying, reducing system modification costs and maintaining costs, distinguishing the normal user experience of ordinary users and technical users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116821544B_ABST
    Figure CN116821544B_ABST
Patent Text Reader

Abstract

The present invention relates to a method, system, and storage medium for preventing webpage text from being copied. The method comprises: step T1. obtaining data information of a DOM node of webpage text in real time, wherein the data information of the DOM node includes text information and CSS attribute data information; step T2. if the CSS attribute data information changes, notifying the backend in real time to restore the CSS attribute data; if the CSS attribute data information remains unchanged, dynamically adding the text information to the data information of the DOM node and proceeding to step T3; and step T3. adding the text information to a browser for display, obtaining data information of the browser's visible area and browser window in real time. The present invention not only effectively prevents users from changing DOM attributes in a console, thereby cracking anti-copying measures, but also prevents crawlers from crawling webpage source code for copying.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of web page text deployment, and in particular to a method, system and storage medium for preventing web page text from being copied. Background Art

[0002] In the modern Internet, front-end pages display a large amount of information. Some texts do not want users to easily copy and paste them directly to prevent the text from being stolen by users. For example, in the display of information in document libraries, users with a little technical knowledge can dynamically modify the DOM through browser developer tools to copy text information, which cannot guarantee the rights and interests of users.

[0003] In the existing technology, text cannot be selected and does not have an anti-tampering function. Users with a little technical knowledge can dynamically modify the DOM through the browser console to remove the changed attributes, which cannot play the anti-copying function. Crawlers can still directly obtain the text content when scraping the source code of the web page. Summary of the Invention

[0004] In view of the above deficiencies in the prior art, the present invention provides a method, system and storage medium for preventing web page text from being copied, which not only effectively prevents users from changing DOM attributes in the console to crack the anti-copying function, but also prevents crawlers from crawling the web page source code to copy it.

[0005] In order to achieve the above-mentioned and other related purposes, the present invention provides the following technical solutions:

[0006] A method for preventing webpage text from being copied, the method comprising:

[0007] T1 real-time acquisition of web page text DOM node data information, the DOM node data information includes text information and CSS attribute data information;

[0008] T2. If the CSS attribute data information changes, the background is notified in real time to restore the CSS attribute data. If the CSS attribute data information has not changed, the text information is dynamically added to the data information of the DOM node and proceeds to step T3.

[0009] T3. Add the text information to the browser for display, and obtain the browser's visible area data information and browser window data information in real time;

[0010] T4. Based on the visible area data information and the browser window data information, a difference algorithm is used to determine whether the user has opened the console to copy the text information.

[0011] Furthermore, in step T4, the difference algorithm includes:

[0012] T41 real-time acquisition of the visible area data information and browser window data information, extracting the width W1 and height H1 of the visible area data information, and extracting the width W2 and height H2 of the browser window data information of the browser window;

[0013] T42. Based on the width W1 and height H1 of the visible area and the width W2 and height H2 of the browser window, construct a difference function.

[0014] W 差 =│W1-W2│, H 差 =│H1-H2│;

[0015] T43. If the difference function W 差 The value of H is greater than 160 or the difference function H 差 If the value of is greater than 160, the user opens the console to copy the text information.

[0016] Furthermore, in step T43, if the user opens the console to copy the text information, the text information in the data information of the DOM node is deleted through a JavaScript script.

[0017] Furthermore, the CSS attribute data information includes a user cannot select text attribute and a user cannot add text attribute.

[0018] Furthermore, in step T2, the text information is dynamically added to the data information of the DOM node after the web page is loaded, and the text data is requested through ajax, and then the JavaScript script is used to obtain the text DOM to dynamically add text information to the data information of the DOM node.

[0019] Furthermore, the method further comprises:

[0020] T5. If the user closes the console, the text information is redisplayed through JavaScript script.

[0021] In order to achieve the above-mentioned and other related purposes, the present invention further provides a system for preventing webpage text from being copied, the system comprising:

[0022] The acquisition module obtains the data information of the DOM nodes of the web page text in real time;

[0023] Parsing module, used to parse CSS attribute data information;

[0024] An extraction module is used to extract the width and height of the visible area from the visible area data information, and to extract the width and height of the browser window from the browser window data information;

[0025] The calculation and judgment module is used to judge whether to open the console to copy text information based on the difference algorithm.

[0026] Furthermore, the acquisition module is connected to the analysis module, the analysis module is connected to the extraction module, and the extraction module is connected to the calculation and judgment module.

[0027] Furthermore, the system also includes a prompt module, which is connected to the calculation and judgment module and is used to warn and prompt that the text information is at risk of being copied.

[0028] In order to achieve the above-mentioned and other related purposes, the present invention further provides a computer-readable storage medium, which stores a computer program programmed or configured to execute any one of the methods for preventing web page text from being copied.

[0029] The present invention has the following positive effects:

[0030] 1. The present invention systematically and comprehensively prevents users from maliciously obtaining the text display content of web pages, thereby preventing paid content from being stolen by users. At the same time, the old web pages can be equipped with anti-copying functions without major modifications, reducing maintenance costs.

[0031] 2. The present invention can not only distinguish between ordinary users and technical users without affecting the normal use experience of ordinary users, but also effectively prevent the plug-ins installed by users from automatically canceling the CSS style and selecting text for copying.

[0032] 3. The post-loading web page content of the present invention can effectively prevent crawlers from crawling, further ensuring the security of the text. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 Schematic diagram of the process of the present invention. DETAILED DESCRIPTION

[0034] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0035] Example 1: Figure 1 As shown, a method for preventing webpage text from being copied comprises:

[0036] T1 real-time acquisition of web page text DOM node data information, the DOM node data information includes text information and CSS attribute data information;

[0037] T2. If the CSS attribute data information changes, the background is notified in real time to restore the CSS attribute data. If the CSS attribute data information has not changed, the text information is dynamically added to the data information of the DOM node and proceeds to step T3.

[0038] T3. Add the text information to the browser for display, and obtain the browser's visible area data information and browser window data information in real time;

[0039] T4. Based on the visible area data information and the browser window data information, a difference algorithm is used to determine whether the user has opened the console to copy the text information.

[0040] In this embodiment, in step T4, the difference algorithm includes:

[0041] T41 real-time acquisition of the visible area data information and browser window data information, extracting the width W1 and height H1 of the visible area data information, and extracting the width W2 and height H2 of the browser window data information of the browser window;

[0042] T42. Based on the width W1 and height H1 of the visible area and the width W2 and height H2 of the browser window, construct a difference function.

[0043] W 差 =│W1-W2│, H 差 =│H1-H2│;

[0044] T43. If the difference function W 差 The value of H is greater than 160 or the difference function H 差 If the value of is greater than 160, the user opens the console to copy the text information.

[0045] In this embodiment, in step T43, if the user opens the console to copy the text information, the text information in the data information of the DOM node is deleted through a JavaScript script.

[0046] In this embodiment, the CSS attribute data information includes a user-unable-to-select text attribute and a user-unable-to-add text attribute.

[0047] In this embodiment, in step T2, the text information is dynamically added to the data information of the DOM node after the web page is loaded, and the text data is requested through ajax, and then the text DOM is obtained using JavaScript script to dynamically add text information to the data information of the DOM node.

[0048] In this embodiment, the method further includes:

[0049] T5. If the user closes the console, the text information is redisplayed through JavaScript script.

[0050] Example 2: Based on the method for preventing web page text from being copied in Example 1, the present invention is further illustrated and described below.

[0051] The present invention provides a system for preventing webpage text from being copied, the system comprising:

[0052] The acquisition module obtains the data information of the DOM nodes of the web page text in real time;

[0053] Parsing module, used to parse CSS attribute data information;

[0054] An extraction module is used to extract the width and height of the visible area from the visible area data information, and to extract the width and height of the browser window from the browser window data information;

[0055] The calculation and judgment module is used to judge whether to open the console to copy text information based on the difference algorithm.

[0056] In this embodiment, the acquisition module is connected to the analysis module, the analysis module is connected to the extraction module, and the extraction module is connected to the calculation and judgment module.

[0057] In this embodiment, the system further includes a prompt module, which is connected to the calculation and judgment module and is used to issue a warning and prompt that the text information is at risk of being copied.

[0058] In order to achieve the above-mentioned and other related purposes, the present invention further provides a computer-readable storage medium, which stores a computer program programmed or configured to execute any one of the methods for preventing web page text from being copied.

[0059] Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM).

[0060] In summary, the present invention not only effectively prevents users from changing DOM attributes in the console to crack anti-copying, but also prevents crawlers from crawling web page source code for copying.

[0061] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A method for preventing webpage text from being copied, characterized in that: The method comprises: T1 real-time acquisition of web page text DOM node data information, the DOM node data information includes text information and CSS attribute data information; T2. If the CSS attribute data information changes, the background is notified in real time to restore the CSS attribute data. If the CSS attribute data information has not changed, the text information is dynamically added to the data information of the DOM node and proceeds to step T3. T3. Add the text information to the browser for display, and obtain the browser's visible area data information and browser window data information in real time; T4 based on the visible area data information and browser window data information, using a difference algorithm to determine whether the user opens the console to copy the text information; The method further comprises: T5. If the user closes the console, the text information is redisplayed through JavaScript script.

2. The method for preventing webpage text from being copied according to claim 1, wherein: In step T4, the difference algorithm includes: T41 real-time acquisition of the visible area data information and browser window data information, extracting the width W1 and height H1 of the visible area data information, and extracting the width W2 and height H2 of the browser window data information of the browser window; T42. Based on the width W1 and height H1 of the visible area and the width W2 and height H2 of the browser window, construct a difference function. W 差 =│W1-W2│,H 差 =│H1-H2│; T43. If the value of the difference function W difference is greater than 160 or the value of the difference function H difference is greater than 160, the user opens the console to copy the text information.

3. The method for preventing webpage text from being copied according to claim 2, wherein: In step T43, if the user opens the console to copy the text information, the text information in the data information of the DOM node is deleted through a JavaScript script.

4. The method for preventing webpage text from being copied according to claim 1, wherein: The CSS attribute data information includes a user-unable-to-select text attribute and a user-unable-to-add text attribute.

5. The method for preventing webpage text from being copied according to claim 1, wherein: In step T2, the text information is dynamically added to the data information of the DOM node after the web page is loaded, and the text data is requested through ajax, and then the text DOM is obtained using JavaScript script to dynamically add text information to the data information of the DOM node.

6. A system for preventing web page text from being copied, characterized in that: A method for implementing webpage text copy protection according to any one of claims 1 to 5, wherein the system comprises: The acquisition module obtains the data information of the DOM nodes of the web page text in real time; Parsing module, used to parse CSS attribute data information; An extraction module is used to extract the width and height of the visible area from the visible area data information, and to extract the width and height of the browser window from the browser window data information; The calculation and judgment module is used to judge whether to open the console to copy text information based on the difference algorithm; the system also includes a prompt module, which is connected to the calculation and judgment module and is used to warn and prompt that the text information is at risk of being copied.

7. The webpage text copy protection system according to claim 6, characterized in that: The acquisition module is connected to the analysis module, the analysis module is connected to the extraction module, and the extraction module is connected to the calculation and judgment module.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program programmed or configured to execute the method for preventing web page text from being copied as claimed in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Text protection method and related device

    CN110858252A

  • Text copying control method and device, equipment and storage medium

    CN115237619A