Chinese serial number adding method based on webpage source code and regular expression

Through the method based on web page source code and regular expressions, Chinese serial numbers are automatically identified and added, which solves the problem of crawlers lacking format and display of formats to obtain data, and improves data processing efficiency and reading experience.

CN119848368APending Publication Date: 2025-04-18SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411775948.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The data obtained directly through crawlers lacks a clear data format, which leads to complex data processing and analysis, and the original data information display is lengthy and messy, lacks orderliness and aesthetics, and cannot intuitively add Chinese serial numbers, which affects data analysis and customer satisfaction.

Method used

Using a method based on web page source code and regular expression, the web page source code is obtained through crawlers, the regular expression is used to match the part that needs to be added in Chinese serial numbers, generate Chinese serial numbers according to the generation rules, and add them to the corresponding position through HTML tags, and finally reconstruct and verify the web page source code.

Benefits of technology

It improves the automation of web page information processing, enhances the readability and organization of web page content, realizes the rapid numbering of web page content, and improves work efficiency and reading experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119848368A_ABST
    Figure CN119848368A_ABST
Patent Text Reader

Abstract

The invention discloses a Chinese serial number adding method based on a webpage source code and a regular expression, and relates to the technical field of data conversion. Comprising the following steps of: 1, acquiring a target webpage source code from the Internet by utilizing a crawler and storing the webpage source code in a relational database, 2, analyzing the webpage source code stored in the relational database, and matching a part, which needs to be added with a Chinese serial number, in the webpage source code by utilizing a regular expression, 3, a generation rule of the Chinese serial number is defined according to requirements, the Chinese serial number is generated according to the generation rule, an insertion position is selected in the part needing to be added with the Chinese serial number, and the Chinese serial number is added to the insertion position in an HTML tag mode; and reconstructing a webpage source code: verifying and repairing the HTML code inserted with the Chinese serial number, and comprehensively previewing and testing the original layout and style of the webpage to ensure the finally presented webpage effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a Chinese serial number adding method based on webpage source code and regular expression, and relates to the technical field of data conversion. Background Art

[0002] In the process of function development, the importance of data is self-evident. It is the key basis for us to optimize products and improve user experience. In many cases, in order to obtain this valuable data, we will choose to use web crawler technology to obtain the required information. As an automated tool, web crawlers can efficiently traverse web pages and grab data, greatly saving labor costs.

[0003] However, there are often some problems with data obtained directly through crawlers. For example, the information may not contain a clear data format, making subsequent data processing and analysis complicated and cumbersome. Furthermore, the information display method of the original data may be too lengthy and messy, lacking in organization and aesthetics. In addition, the data presentation method is not conducive to data analysis work, and Chinese serial numbers cannot be added intuitively according to requirements, which is not conducive to displaying to customers and reduces their satisfaction. Summary of the invention

[0004] In view of the problems of the prior art, the present invention provides a method for adding Chinese serial numbers based on web page source code and regular expressions, which improves the automation level of web page information processing and significantly enhances the readability and orderliness of web page content. Through this method, users can easily realize rapid numbering of web page content without manual operation, which greatly improves work efficiency. Therefore, this method has broad application prospects, can be applied to the processing and display of various types of web page information, and has important practical value.

[0005] The specific scheme proposed by the present invention is:

[0006] The present invention provides a method for adding Chinese serial numbers based on web page source code and regular expressions, comprising: step 1: using a crawler to obtain the target web page source code from the Internet and storing the web page source code in a relational database;

[0007] Step 2: Parse the webpage source code stored in the relational database and use regular expressions to match the part of the webpage source code that needs to add Chinese serial numbers.

[0008] Step 3: Define the generation rules of Chinese serial numbers according to the requirements, generate Chinese serial numbers according to the generation rules, select the insertion position in the part where the Chinese serial number needs to be added, and add the Chinese serial number to the insertion position in the form of HTML tags.

[0009] Step 4: After adding the Chinese serial number, reconstruct the web page source code: verify and repair the HTML code after inserting the Chinese serial number, and conduct a comprehensive preview and test of the original layout and style of the web page to ensure the final web page effect.

[0010] Furthermore, in step 1 of the method for adding Chinese serial numbers based on web page source code and regular expressions, a modular approach is adopted to create a crawler architecture, and the crawler architecture includes a request module, a parsing module and a storage module. The request module sends an HTTP request to the target website to obtain the target web page source code, and the obtained web page source code is preliminarily processed by the parsing module, and the captured web page source code is saved in a relational database by the storage module.

[0011] Further, step 2 of the method for adding Chinese serial numbers based on web page source code and regular expressions specifically includes:

[0012] Extract the web page source code that needs to be parsed from the relational database,

[0013] Construct the corresponding regular expression according to the HTML structure and content characteristics of the target web page.

[0014] Use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

[0015] Further, step 3 of the method for adding Chinese serial numbers based on web page source code and regular expressions specifically includes:

[0016] Define the generation rules of Chinese serial numbers according to the requirements. The generation rules include converting Arabic numerals into Chinese numerals in sequence, generating Chinese serial numbers of different levels according to the hierarchical structure of the web page content, and generating Chinese serial numbers according to the selected generation rules.

[0017] In the part where you need to add Chinese serial numbers, select the insertion position according to the HTML tags or text features of the target content. The insertion position includes before the paragraph and before the list item.

[0018] use The Chinese serial number is added to the insertion position in the form of a label wrapped Chinese serial number.

[0019] Furthermore, in step 4 of the method for adding Chinese serial numbers based on web page source code and regular expressions, the HTML code after the Chinese serial number is inserted is verified and repaired, including: checking HTML tag errors, attribute missing problems, and adjusting the style of the web page.

[0020] The present invention is also a Chinese serial number adding device based on web page source code and regular expression, comprising a web page source code crawling module, a web page source code parsing module, a Chinese serial number adding module and a web page content reconstruction module.

[0021] The webpage source code crawling module uses crawlers to obtain the target webpage source code from the Internet and stores the webpage source code in a relational database.

[0022] The web page source code parsing module parses the web page source code stored in the relational database and uses regular expressions to match the part of the web page source code that needs to add Chinese serial numbers.

[0023] The Chinese serial number adding module defines the generation rules of Chinese serial numbers according to the requirements, generates Chinese serial numbers according to the generation rules, selects the insertion position in the part where the Chinese serial number needs to be added, and adds the Chinese serial number to the insertion position in the form of HTML tags.

[0024] After adding the Chinese serial number, the web page content reconstruction module reconstructs the web page source code: verifies and repairs the HTML code after the Chinese serial number is inserted, and comprehensively previews and tests the original layout and style of the web page to ensure the final web page effect.

[0025] Furthermore, the web page source code crawling module of the Chinese serial number adding device based on web page source code and regular expression adopts a modular method to create a crawler architecture, and the crawler architecture includes a request module, a parsing module and a storage module. The request module sends an HTTP request to the target website to obtain the target web page source code, and the obtained web page source code is preliminarily processed by the parsing module, and the captured web page source code is saved in a relational database by the storage module.

[0026] Furthermore, the web page source code parsing module of the Chinese serial number adding device based on web page source code and regular expression extracts the web page source code to be parsed from the relational database.

[0027] Construct the corresponding regular expression according to the HTML structure and content characteristics of the target web page.

[0028] Use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

[0029] Furthermore, the Chinese serial number adding module of the Chinese serial number adding device based on web page source code and regular expression defines the generation rules of Chinese serial numbers according to the requirements, and the generation rules include converting Arabic numerals into Chinese numerals in sequence, generating Chinese serial numbers of different levels according to the hierarchical structure of web page content, and generating Chinese serial numbers according to the selected generation rules.

[0030] In the part where you need to add Chinese serial numbers, select the insertion position according to the HTML tags or text features of the target content. The insertion position includes before the paragraph and before the list item.

[0031] use The Chinese serial number is added to the insertion position in the form of a label wrapped Chinese serial number.

[0032] Furthermore, the web page content reconstruction module of the Chinese serial number adding device based on web page source code and regular expression verifies and repairs the HTML code after the Chinese serial number is inserted, including: checking HTML tag errors, attribute missing problems, and adjusting the style of the web page.

[0033] The benefits of the present invention are:

[0034] Parse the web page source code and use regular expressions to quickly locate and extract the parts that need to add Chinese serial numbers, avoiding the tedious steps of manual operation or complex algorithm processing. This significantly improves the efficiency of web page information processing and reduces labor and time costs.

[0035] By adding Chinese serial numbers to the key information on the web page, the web page content becomes clearer and more organized, making it easier to understand and absorb the information on the web page, improving the reading experience and effect. At the same time, this also provides a more convenient and accurate basis for subsequent web page information analysis and mining. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0037] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.

[0038] Example 1

[0039] The present invention provides a Chinese serial number adding method based on web page source code and regular expression, comprising: step 1: using a crawler to obtain the target web page source code from the Internet and storing the web page source code in a relational database, such as MySQL. The relational database takes into account the integrity, consistency and scalability of the data, and provides reliable data support for subsequent web page parsing and serial number adding.

[0040] In step 1, a modular approach is used to create a crawler architecture, which includes a request module, a parsing module, and a storage module. The request module sends an HTTP request to the target website to obtain the target web page source code. The parsing module performs preliminary processing on the obtained web page source code, and the storage module saves the captured web page source code into a relational database.

[0041] The crawler architecture can also set up anti-crawler mechanisms, such as setting request intervals, random User-Agents, etc., to avoid being blocked by the target website.

[0042] Step 2: Parse the web page source code stored in the relational database, and use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

[0043] Wherein step 2 specifically includes:

[0044] Extract the web page source code that needs to be parsed from the relational database,

[0045] Construct the corresponding regular expression according to the HTML structure and content characteristics of the target web page.

[0046] Use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

[0047] Regular expressions need to take into account the diversity and complexity of web page content to ensure that they can accurately match the target content while avoiding mismatches.

[0048] Step 3: Define the generation rules of Chinese serial numbers according to requirements, generate Chinese serial numbers according to the generation rules, select the insertion position in the part where Chinese serial numbers need to be added, and add the Chinese serial numbers to the insertion position in the form of HTML tags.

[0049] In step 3, the generation rules, insertion position and insertion method of Chinese serial numbers are taken into consideration. Specifically, it includes:

[0050] Define the generation rules of Chinese serial numbers according to the requirements. The generation rules include converting Arabic numerals into Chinese numerals in sequence, such as one, two, three, etc., generating Chinese serial numbers of different levels according to the hierarchical structure of the web page content, such as 1.1, 1.2, 2.1, etc., and generating Chinese serial numbers according to the selected generation rules.

[0051] In the part where you need to add Chinese serial numbers, select the insertion position according to the HTML tags or text features of the target content. The insertion position includes before the paragraph and before the list item.

[0052] The insertion method can be in the form of HTML tags, such as The Chinese serial number is added to the insertion position in the form of a label wrapped Chinese serial number.

[0053] Step 4: After adding the Chinese serial number, reconstruct the web page source code: verify and repair the HTML code after inserting the Chinese serial number, and conduct a comprehensive preview and test of the original layout and style of the web page to ensure the final web page effect.

[0054] In step 4, the HTML code after the Chinese serial number is inserted is verified and repaired, including: checking HTML tag errors, attribute missing problems, and adjusting the style of the web page.

[0055] The method of the present invention provides an automated and intelligent solution for web page information processing. Through the preset regular expression rules and algorithms, the system can automatically complete the extraction, processing and serial numbering of web page information, and can achieve efficient information processing without manual intervention or with little manual intervention. This not only improves work efficiency, but also promotes the automation and intelligentization of web page information processing. This step helps us to discover and fix possible problems in a timely manner, thereby ensuring that the final web page effect is both beautiful and practical.

[0056] Example 2

[0057] The present invention is also a Chinese serial number adding device based on web page source code and regular expression, comprising a web page source code crawling module, a web page source code parsing module, a Chinese serial number adding module and a web page content reconstruction module.

[0058] The webpage source code crawling module uses crawlers to obtain the target webpage source code from the Internet and stores the webpage source code in a relational database.

[0059] The web page source code parsing module parses the web page source code stored in the relational database and uses regular expressions to match the part of the web page source code that needs to add Chinese serial numbers.

[0060] The Chinese serial number adding module defines the generation rules of Chinese serial numbers according to the requirements, generates Chinese serial numbers according to the generation rules, selects the insertion position in the part where the Chinese serial number needs to be added, and adds the Chinese serial number to the insertion position in the form of HTML tags.

[0061] After adding the Chinese serial number, the web page content reconstruction module reconstructs the web page source code: verifies and repairs the HTML code after the Chinese serial number is inserted, and comprehensively previews and tests the original layout and style of the web page to ensure the final web page effect.

[0062] As the information interaction and execution process between the modules of the above-mentioned device are based on the same concept as the embodiment of the method of the present invention, the specific contents can be found in the description of the embodiment of the method of the present invention and will not be repeated here.

[0063] Similarly, the device of the present invention parses the webpage source code, uses regular expressions to quickly locate and extract the part that needs to add Chinese serial numbers, avoiding the tedious steps of manual operation or complex algorithm processing, significantly improving the efficiency of webpage information processing, and reducing labor costs and time costs.

[0064] By adding Chinese serial numbers to the key information on the web page, the web page content becomes clearer and more organized, making it easier to understand and absorb the information on the web page, improving the reading experience and effect. At the same time, this also provides a more convenient and accurate basis for subsequent web page information analysis and mining.

[0065] It should be noted that not all steps and modules in the above-mentioned processes and device structures are necessary, and some steps or modules can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The system structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.

[0066] The above-described embodiments are only preferred embodiments for fully illustrating the present invention, and the protection scope of the present invention is not limited thereto. Equivalent substitutions or changes made by those skilled in the art based on the present invention are within the protection scope of the present invention. The protection scope of the present invention shall be subject to the claims.

Claims

1. A method for adding Chinese serial numbers based on web page source code and regular expressions, characterized in that include: Step 1: Use a crawler to obtain the target web page source code from the Internet and store the web page source code in a relational database. Step 2: Parse the webpage source code stored in the relational database and use regular expressions to match the part of the webpage source code that needs to add Chinese serial numbers. Step 3: Define the generation rules of Chinese serial numbers according to the requirements, generate Chinese serial numbers according to the generation rules, select the insertion position in the part where the Chinese serial number needs to be added, and add the Chinese serial number to the insertion position in the form of HTML tags. Step 4: After adding the Chinese serial number, reconstruct the web page source code: verify and repair the HTML code after inserting the Chinese serial number, and conduct a comprehensive preview and test of the original layout and style of the web page to ensure the final web page effect.

2. According to claim 1, a method for adding Chinese serial numbers based on web page source code and regular expressions is characterized in that In step 1, a modular approach is used to create a crawler architecture, which includes a request module, a parsing module, and a storage module. The request module sends an HTTP request to the target website to obtain the target web page source code. The parsing module performs preliminary processing on the obtained web page source code, and the storage module saves the captured web page source code into a relational database.

3. A method for adding Chinese serial numbers based on web page source code and regular expressions according to claim 1, characterized in that Step 2 specifically includes: Extract the web page source code that needs to be parsed from the relational database, Construct the corresponding regular expression according to the HTML structure and content characteristics of the target web page. Use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

4. A method for adding Chinese serial numbers based on web page source code and regular expressions according to claim 1, characterized in that Step 3 specifically includes: Define the generation rules of Chinese serial numbers according to the requirements. The generation rules include converting Arabic numerals into Chinese numerals in sequence, generating Chinese serial numbers of different levels according to the hierarchical structure of the web page content, and generating Chinese serial numbers according to the selected generation rules. In the part where you need to add Chinese serial numbers, select the insertion position according to the HTML tags or text features of the target content. The insertion position includes before the paragraph and before the list item. use The Chinese serial number is added to the insertion position in the form of a label wrapped Chinese serial number.

5. A method for adding Chinese serial numbers based on web page source code and regular expressions according to claim 1, characterized in that In step 4, the HTML code after the Chinese serial number is inserted is verified and repaired, including: checking HTML tag errors, attribute missing problems, and adjusting the style of the web page.

6. A Chinese serial number adding device based on web page source code and regular expression, characterized in that It includes web page source code crawling module, web page source code parsing module, Chinese serial number adding module and web page content reconstruction module. The webpage source code crawling module uses crawlers to obtain the target webpage source code from the Internet and stores the webpage source code in a relational database. The web page source code parsing module parses the web page source code stored in the relational database and uses regular expressions to match the part of the web page source code that needs to add Chinese serial numbers. The Chinese serial number adding module defines the generation rules of Chinese serial numbers according to the requirements, generates Chinese serial numbers according to the generation rules, selects the insertion position in the part where the Chinese serial number needs to be added, and adds the Chinese serial number to the insertion position in the form of HTML tags. After adding the Chinese serial number, the web page content reconstruction module reconstructs the web page source code: verifies and repairs the HTML code after the Chinese serial number is inserted, and comprehensively previews and tests the original layout and style of the web page to ensure the final web page effect.

7. The Chinese serial number adding device based on web page source code and regular expression according to claim 6 is characterized in that the web page The source code crawling module uses a modular approach to create a crawler architecture, which includes a request module, a parsing module, and a storage module. The request module sends an HTTP request to the target website to obtain the target web page source code. The parsing module performs preliminary processing on the obtained web page source code, and the storage module saves the captured web page source code into a relational database.

8. The Chinese serial number adding device based on web page source code and regular expression according to claim 6 is characterized in that the web page source code parsing module extracts the web page source code to be parsed from the relational database, Construct the corresponding regular expression according to the HTML structure and content characteristics of the target web page. Use regular expressions to match the part of the web page source code where Chinese serial numbers need to be added.

9. The Chinese serial number adding device based on web page source code and regular expression according to claim 6 is characterized in that The serial number adding module defines the generation rules of Chinese serial numbers according to the requirements. The generation rules include converting Arabic numerals into Chinese numerals in order, generating Chinese serial numbers of different levels according to the hierarchical structure of the web page content, and generating Chinese serial numbers according to the selected generation rules. In the part where you need to add Chinese serial numbers, select the insertion position according to the HTML tags or text features of the target content. The insertion position includes before the paragraph and before the list item. use The Chinese serial number is added to the insertion position in the form of a label wrapped Chinese serial number.

10. The Chinese serial number adding device based on web page source code and regular expression according to claim 6, characterized in that The web page content reconstruction module verifies and repairs the HTML code after the Chinese serial number is inserted, including: checking HTML tag errors, attribute missing problems, and adjusting the style of the web page.