Website information automatic acquisition method and system based on OCR and natural language processing

By combining OCR and natural language processing methods, this study addresses the problem of inaccurate recognition results and improves the accuracy and quality of information collection by employing screenshot preprocessing, OCR recognition, result verification image comparison, and local magnification processing for complex text or image content in website information collection.

CN120877291APending Publication Date: 2025-10-31WORKER LE (TIANJIN) TECHNOLOGY GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510970607.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

In existing technologies, when using OCR to recognize website information, it is difficult to guarantee the accuracy of the recognition results when faced with complex text or image content, which affects the data quality.

Method used

By combining OCR and natural language processing methods, the recognition results are gradually corrected through screenshot preprocessing, OCR recognition, result verification image comparison, and local magnification processing to ensure recognition accuracy.

Benefits of technology

It improves the accuracy of website information collection and ensures data quality. By using natural language processing algorithms to correct the recognition results and generate result verification images for comparison, it strengthens the comparison of inaccurate locations, thereby improving the accuracy of information collection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120877291A_ABST
    Figure CN120877291A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of information acquisition, and particularly relates to an automatic website information acquisition method and system based on OCR and natural language processing, and the method comprises the steps: accessing a corresponding website according to an acquisition task, carrying out the screenshot of a picture displayed by the website, and obtaining a to-be-recognized screenshot; performing OCR recognition on the to-be-recognized screenshot to obtain an OCR recognition result, and performing preliminary correction on the OCR recognition result to obtain a to-be-verified text; constructing a result verification image, marking the to-be-verified text in the result verification image, and extracting a difference region image; and carrying out amplification processing to obtain a local area amplified screenshot, carrying out OCR identification, adjusting a difference area image, carrying out comparison again, and outputting a website information collection result when the overlap ratio reaches a preset value. According to the method, the accuracy of text recognition is judged by comparing the result verification images, and local enhanced comparison is carried out on positions which are not accurately recognized, so that the accuracy of information collection is improved, and the quality of data collection is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of information collection technology, and in particular relates to a method and system for automated collection of website information based on OCR and natural language processing. Background Technology

[0002] Automated website data scraping refers to the process of automatically capturing, extracting, and organizing data from one or more websites using specific software tools or programs, following preset rules and parameters. This technology can efficiently obtain structured or semi-structured data from web pages, such as text, images, and links, and convert them into formats suitable for further analysis and processing. Automated data scraping is widely used in competitive intelligence gathering, price monitoring, news aggregation, content migration, and many other fields, greatly improving the speed and efficiency of data acquisition while reducing the error rate of manual operations.

[0003] In the current process of collecting website information, OCR recognition is usually used to extract information content from the website. However, the text or image content in the website information is complex. It is difficult to guarantee the accuracy of the recognition results by only using natural language processing to correct the OCR recognition results, which affects the quality of the data. Summary of the Invention

[0004] The purpose of this invention is to provide an automated website information collection method based on OCR and natural language processing. This method aims to solve the problem that in the current website information collection process, OCR recognition is usually used to extract information content from websites. However, the text or image content in website information is complex, and it is difficult to guarantee the accuracy of the recognition results by only using natural language processing to correct the OCR recognition results, which affects the quality of the data.

[0005] This invention is implemented as follows: an automated website information collection method based on OCR and natural language processing, the method comprising:

[0006] According to the data collection task, access the corresponding website, take a screenshot of the screen displayed on the website, preprocess the screenshot to obtain the screenshot to be identified;

[0007] The screenshot to be recognized is subjected to OCR recognition to obtain the OCR recognition result. The OCR recognition result is initially corrected by natural language processing algorithm to obtain the text to be verified. The position information of each character is recorded in the OCR recognition result.

[0008] Construct a result verification image, mark the text to be verified in the result verification image according to the OCR recognition result, compare it with the screenshot to be recognized, and extract the difference area image;

[0009] The website's local area is magnified to obtain a local magnified screenshot, which is then subjected to OCR recognition. The images of the different areas are adjusted and re-compared. When the overlap reaches a preset value, the website information collection results are output.

[0010] Preferably, the step of performing OCR recognition on the screenshot to be recognized, obtaining the OCR recognition result, and then performing preliminary correction on the OCR recognition result using a natural language processing algorithm to obtain the text to be verified specifically includes:

[0011] Import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result;

[0012] During the recognition process, the position information of each character is extracted. The position information is represented by the coordinates of pixels. The pixel at the center of the character is used as the position of the character, and the font information of the character is recorded.

[0013] The OCR recognition results are imported into the natural language processing engine to correct the OCR recognition results and form the text to be verified.

[0014] Preferably, the step of constructing a result verification image, marking the text to be verified in the result verification image according to the OCR recognition result, comparing it with the screenshot to be recognized, and extracting the difference region image includes:

[0015] Information is extracted from the screenshot to be recognized, including its resolution. A verification image with the same size and resolution as the screenshot to be recognized is constructed, and the verification image and the screenshot to be recognized use the same background color.

[0016] Extract each character, font information, and corresponding position information from the OCR recognition results, generate corresponding text images, and overlay them on the result verification image;

[0017] Extract the character block images between the verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

[0018] Preferably, the steps of magnifying a local area of ​​the website to obtain a magnified screenshot and performing OCR recognition, adjusting the image of the difference area, re-comparing, and outputting the website information collection result when the overlap reaches a preset value specifically include:

[0019] The website's corresponding location is scaled based on the image of the difference region, and a screenshot of that region is taken to obtain a local magnified image. OCR recognition is then performed on the local magnified image to obtain the local recognition result.

[0020] Based on the local recognition results, multiple sets of images to be compared are generated. The images to be compared are repeatedly compared with the images of the difference regions, and the similarity is calculated.

[0021] When the overlap reaches a preset value, the text correction is deemed complete, and the website information collection results are output.

[0022] Preferably, in the step of accessing the corresponding website according to the collection task, taking screenshots of the screen displayed on the website, preprocessing the screenshots to obtain the screenshots to be identified, after accessing the website, taking screenshots at preset time intervals, comparing adjacent screenshots, identifying dynamic and static areas in the screenshots, continuously identifying dynamic areas, discarding dynamic areas if the identification results are different, and retaining them if the identification results are the same.

[0023] Another object of the present invention is to provide an automated website information collection system based on OCR and natural language processing, the system comprising:

[0024] The website screenshot module is used to access the corresponding website according to the data collection task, take screenshots of the screen displayed on the website, preprocess the screenshots, and obtain the screenshots to be recognized.

[0025] The OCR recognition module is used to perform OCR recognition on the screenshot to obtain the OCR recognition result. The OCR recognition result is initially corrected by natural language processing algorithm to obtain the text to be verified. The OCR recognition result records the position information of each character.

[0026] The difference image extraction module is used to construct the result verification image. Based on the OCR recognition result, the text to be verified is marked in the result verification image, and it is compared with the screenshot to be recognized to extract the difference area image.

[0027] The local correction module is used to magnify a local area of ​​the website, obtain a magnified screenshot, perform OCR recognition, adjust the image of the difference area, and re-compare. When the overlap reaches a preset value, the website information collection result is output.

[0028] Preferably, the OCR recognition module includes:

[0029] The text recognition unit is used to import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result.

[0030] The text information recording unit is used to extract the position information of each character during the recognition process. The position information is represented by the coordinates of pixels, with the pixel at the center of the character as the position of the character, and the font information of the character is recorded.

[0031] The result correction unit is used to import the OCR recognition result into the natural language processing engine, correct the OCR recognition result, and form the text to be verified.

[0032] Preferably, the difference image extraction module includes:

[0033] The verification image generation unit is used to extract information from the screenshot to be recognized, extract the resolution of the screenshot to be recognized, and construct a result verification image with the same size and resolution as the screenshot to be recognized. The result verification image and the screenshot to be recognized use the same background color.

[0034] The image reconstruction unit is used to extract each character, font information and corresponding position information from the OCR recognition result, generate the corresponding text image, and overlay it on the result verification image.

[0035] The difference recognition unit is used to extract the character block images between the result verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

[0036] Preferably, the local correction module includes:

[0037] The local recognition unit is used to scale the corresponding location of the website based on the image of the difference region, take a screenshot of the region to obtain a local magnified image, and perform OCR recognition on the local magnified image to obtain the local recognition result.

[0038] The overlap calculation unit is used to generate multiple sets of images to be compared based on the local recognition results, repeatedly compare the images to be compared with the images of the difference regions, and calculate the similarity.

[0039] The result output unit is used to determine that text correction is complete and output the website information collection results when the overlap reaches a preset value.

[0040] Preferably, in the step of accessing the corresponding website according to the collection task, taking screenshots of the screen displayed on the website, preprocessing the screenshots to obtain the screenshots to be identified, after accessing the website, taking screenshots at preset time intervals, comparing adjacent screenshots, identifying dynamic and static areas in the screenshots, continuously identifying dynamic areas, discarding dynamic areas if the identification results are different, and retaining them if the identification results are the same.

[0041] This invention provides an automated website information collection method based on OCR and natural language processing. After correcting the recognition results using a natural language processing algorithm, a result verification image is generated based on the corrected text. The accuracy of text recognition is determined by comparing the result verification image with the text. Local enhancement comparison is performed on the inaccurate recognition locations, thereby improving the accuracy of information collection and ensuring the quality of data collection. Attached Figure Description

[0042] Figure 1 A flowchart illustrating the automated website information collection method based on OCR and natural language processing provided in this embodiment of the invention;

[0043] Figure 2 The flowchart illustrates the steps of performing OCR recognition on a screenshot to be recognized, obtaining an OCR recognition result, and then using a natural language processing algorithm to initially correct the OCR recognition result to obtain the text to be verified.

[0044] Figure 3 The flowchart illustrates the steps of constructing a verification image for the embodiment of the present invention, marking the text to be verified in the verification image based on the OCR recognition result, comparing it with the screenshot to be recognized, and extracting the difference region image.

[0045] Figure 4 The flowchart illustrates the steps of the present invention: magnifying a local area of ​​the website to obtain a magnified screenshot and performing OCR recognition, adjusting the image of the difference area, re-comparing, and outputting the website information collection result when the overlap reaches a preset value.

[0046] Figure 5 This is an architecture diagram of an automated website information collection system based on OCR and natural language processing provided in an embodiment of the present invention.

[0047] Figure 6 This is an architecture diagram of the OCR recognition module provided in an embodiment of the present invention;

[0048] Figure 7 This is an architecture diagram of the difference image extraction module provided in an embodiment of the present invention;

[0049] Figure 8 This is an architecture diagram of the local correction module provided in an embodiment of the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0051] like Figure 1 The diagram shows a flowchart of an automated website information collection method based on OCR and natural language processing provided in an embodiment of the present invention. The method includes:

[0052] S100 accesses the corresponding website according to the data collection task, takes a screenshot of the screen displayed on the website, preprocesses the screenshot, and obtains the screenshot to be recognized.

[0053] In this step, the corresponding website is accessed according to the data collection task. The data collection task includes the website's URL. After obtaining the data collection task, the URL is accessed through a browser. Upon starting the access, a long screenshot is taken to ensure that all content within a single page is captured. Screenshots are taken at preset time intervals, such as 10 consecutive screenshots with a 100ms interval between each. Adjacent screenshots are compared pixel-by-pixel. Before this comparison, the screenshots are processed into grayscale images, converted to black and white. If the difference in grayscale values ​​between two corresponding pixels in two adjacent screenshots is greater than a preset value, the pixel is determined to be a dynamic pixel. Dynamic regions are composed of static pixels. If the position of the dynamic region remains unchanged in multiple screenshots, content recognition is performed on the corresponding position of each screenshot corresponding to the dynamic region. If the content recognition results are consistent, the content recognition result is used as the content of the dynamic region, and the dynamic region is filled with the corresponding content recognition result. If the content recognition results are inconsistent, the dynamic region is discarded, and the dynamic region is filled with a preset background. When no more dynamic regions with undetermined content appear in the screenshot, the current page is considered to have completed the screenshot, and the screenshot to be recognized is obtained. Then, switch to the next page and repeat the above steps.

[0054] S200 performs OCR recognition on the screenshot to be recognized, obtains the OCR recognition result, and performs preliminary correction on the OCR recognition result through natural language processing algorithm to obtain the text to be verified. The OCR recognition result records the position information of each character.

[0055] In this step, OCR recognition is performed on the screenshot to be recognized. The screenshot is imported into a preset OCR recognition engine. If the image size of the screenshot is too large, it can be segmented. After importing into the OCR recognition engine, corresponding recognition results will be generated. During the OCR recognition process, the position and font information of each character in the screenshot are extracted and recorded in the OCR recognition result. The OCR recognition result is then corrected using a natural language processing algorithm. This process includes text cleaning to remove noise data, such as spaces and garbled characters. Data verification and optimization are performed using a natural language processing algorithm, such as logical consistency checks to ensure data accuracy, for example, verifying whether "invoice amount" is a number or whether "date" conforms to the format. After processing, all the text in the screenshot to be recognized has been extracted. However, both OCR recognition and natural language processing inevitably have instances of inaccurate recognition. After correction by the natural language processing algorithm, the text to be verified is obtained.

[0056] S300. Construct a result verification image, mark the text to be verified in the result verification image according to the OCR recognition result, compare it with the screenshot to be recognized, and extract the differential area image.

[0057] In this step, to construct a result verification image for determining the accuracy of the OCR recognition result, a set of result verification images are constructed. The result verification image has exactly the same size as the screenshot to be recognized, with the same number of pixels, and the same number of pixels in both the length and width directions. The result verification image is a blank image when generated. The background of the screenshot to be recognized is identified, and the result verification image is filled with this background. Each text is extracted one by one from the text to be verified, and the corresponding position information, font information, etc. of the text are extracted from the OCR recognition result, thereby generating the corresponding text image, which is overlaid on the result verification image according to its position to obtain a complete result verification image. The processed result verification image is pixel-compared with the screenshot to be recognized, and the position with differences is determined according to the coincidence relationship between the two. This position is the differential area, and the local image of this position is extracted from the screenshot to be recognized to obtain the differential area image.

[0058] S400. Magnify a local position of the website, obtain a locally magnified screenshot and perform OCR recognition, adjust the differential area image, and perform comparison again. When the coincidence degree reaches the preset value, output the website information acquisition result.

[0059] In this step, a local position of the website is magnified. In the process of obtaining the screenshot to be recognized, to ensure the recognition efficiency, the scaling method is used to increase the amount of information contained in the screenshot to be recognized. When the amount of information contained is large, the clarity of the text will be correspondingly reduced. The web page is magnified according to the differential area to increase the display area of the differential area, and a locally magnified screenshot is obtained by taking a screenshot again, so as to re-perform OCR recognition on the unclear parts in the initial recognition process and determine different recognition results for each text. For example, when a text at a certain position is recognized by OCR, there are multiple possibilities, such as "工", "土", "士", and "王". When recognizing, the matching degrees of "工", "土", "士", and "王" are 80%, 75%, 91%, and 89% respectively. Then, a corresponding comparison image is generated according to the locally magnified screenshot, the two are compared, the coincidence degree between the two is calculated, and the accuracy of different recognition results is determined according to the coincidence degree, so as to determine the recognition result of each text in the screenshot to be recognized to generate the website information acquisition result. If the coincidence degree does not meet the preset value, the corresponding text is recorded in the form of a screenshot.

[0060] Such as Figure 2As shown in the preferred embodiment of the present invention, the steps of performing OCR recognition on the screenshot to be recognized, obtaining the OCR recognition result, and then performing preliminary correction on the OCR recognition result using a natural language processing algorithm to obtain the text to be verified specifically include:

[0061] S201: Import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result.

[0062] In this step, the screenshot to be recognized is imported into the OCR recognition engine. The OCR recognition engine can be PaddleOCR, Tesseract OCR, or RapidOCR. The corresponding OCR recognition result is generated through recognition. Alternatively, multiple OCR recognition engines can be used simultaneously, and the recognition results of different OCR recognition engines can be integrated to obtain the final OCR recognition result.

[0063] S202, during the recognition process, the position information of each character is extracted. The position information is represented by the coordinates of pixels. The pixel at the center of the character is used as the position of the character, and the font information of the character is recorded.

[0064] In this step, during the recognition process, the position information of each character is extracted. For example, when recognizing a certain character, a selection box is constructed, and the character is selected by the selection box. The center position of the character in the selection box is taken as the position of the character. Specifically, a two-dimensional coordinate system is constructed based on the screenshot to be recognized to determine the position of each pixel. The position of the character is recorded accordingly, and the font information of the character is also recorded.

[0065] S203: Import the OCR recognition result into the natural language processing engine, correct the OCR recognition result, and form the text to be verified.

[0066] In this step, the OCR recognition results are imported into the natural language processing engine. The engine's contextual analysis, semantic error correction and completion, and domain-specific language understanding functions are used to process the OCR recognition results to form the text to be verified.

[0067] like Figure 3 As shown, in a preferred embodiment of the present invention, the step of constructing a result verification image, marking the text to be verified in the result verification image according to the OCR recognition result, comparing it with the screenshot to be recognized, and extracting the difference region image includes:

[0068] S301, extract information from the screenshot to be recognized, extract the resolution of the screenshot to be recognized, construct a result verification image with the same size and resolution as the screenshot to be recognized, and use the same background color as the screenshot to be recognized.

[0069] In this step, information is extracted from the screenshot to be recognized, and a set of blank images is generated. The number of pixels in the blank images is exactly the same as that in the screenshot to be recognized, that is, the screenshot to be recognized and the blank images contain the same number of pixels in the length and width directions. The background is extracted from the screenshot to be recognized, and the blank images are filled with the background to obtain the result verification image.

[0070] S302: Extract each character, font information, and corresponding position information from the OCR recognition results one by one, generate corresponding text images, and overlay them on the result verification image.

[0071] In this step, each character, font information, and corresponding position information are extracted from the OCR recognition results one by one. According to the order of text recognition, each character is extracted one by one, and the font information and position information of the character are retrieved simultaneously. The character is then copied into the result verification image. If the text recognition result is accurate, the character reflected in the result verification image will also be the same. A text image corresponding to the character is generated based on the character, font, and position, and the text image is overlaid on the corresponding position in the result verification image.

[0072] S303, extract the character block images between the verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

[0073] In this step, character block images are extracted between the text in the result verification image and the screenshot to be recognized. Based on the position of the text, two sets of character block images are obtained from the same position in the result verification image and the screenshot to be recognized. The two sets of character block images are respectively from the result verification image and the screenshot to be recognized. The pixels are compared one by one, and the number of duplicate pixels is counted. If the difference between two pixels at the same position in the two sets of character block images is within a preset range, the pixel is determined to be duplicated. The proportion of duplicate pixels is then counted. If the proportion of duplicate pixels is less than a preset value, the area corresponding to the text is determined to be a difference area. A selection area of ​​a preset size is constructed to select the difference area, thereby extracting the corresponding difference area image from the screenshot to be recognized.

[0074] like Figure 4 As shown, in a preferred embodiment of the present invention, the steps of magnifying a local area of ​​the website to obtain a magnified screenshot and performing OCR recognition, adjusting the images of the different areas, re-comparing, and outputting the website information collection results when the overlap reaches a preset value, specifically include:

[0075] S401: Based on the image of the difference region, scale the corresponding position of the website, take a screenshot of the region to obtain a local magnified image, perform OCR recognition on the local magnified image, and obtain the local recognition result.

[0076] In this step, the corresponding location on the website is scaled based on the image of the difference region. The scaling is performed on the corresponding location on the website based on the center of the image of the difference region, so that the corresponding location of the image of the difference region is magnified. Then, a screenshot is taken again to obtain a local magnified image. OCR recognition is performed on the local magnified image to obtain the local recognition result.

[0077] S402, generate multiple sets of images to be compared based on the local recognition results, repeatedly compare the images to be compared with the images of the difference regions, and calculate the similarity.

[0078] S403: When the overlap reaches the preset value, the text correction is determined to be complete, and the website information collection results are output.

[0079] In this step, the OCR recognition results provide multiple options for each recognition region. A natural language processing engine then predicts the text within the difference regions, yielding multiple prediction results. For example, if text A is within a difference region, and the OCR recognition results provide three possible text options with an accuracy greater than 80%, the natural language processing engine predicts two additional possible text options for text A. Therefore, the region corresponding to text A contains five possible text options. Based on this, the possible text options for each difference region are determined. These options are then combined to obtain multiple combinations. A set of comparison images is generated based on each combination. The text is determined according to the corresponding combination method. Similarly, the pixels in the image to be compared and the image of the difference area are counted. The region where each character is located is compared separately, and its similarity is calculated. If the similarity meets the requirements, the recognition is considered successful. Otherwise, the text screenshot of the corresponding region in the screenshot to be recognized is used as the accurate recognition result of the character, the region is marked, and the website information collection result is output. By enlarging the recognition of inaccurate regions and traversing all selectable characters, the accuracy of text recognition is intuitively verified by image comparison. Inaccurate positions are re-checked, which greatly improves the accuracy of website information collection and ensures the quality of data.

[0080] like Figure 5 As shown, this is an embodiment of the automated website information collection system based on OCR and natural language processing provided by the present invention. The system includes:

[0081] The website screenshot module 100 is used to access the corresponding website according to the collection task, take screenshots of the screen displayed on the website, preprocess the screenshots, and obtain the screenshots to be recognized.

[0082] In this system, the website screenshot module 100 accesses the corresponding website according to the collection task. The collection task includes the website's URL. After obtaining the collection task, the module accesses the URL through a browser. When accessing the URL begins, a long screenshot is taken to ensure that all content within a single page is captured in the screenshot. Screenshots are taken at preset time intervals, such as 10 consecutive screenshots with a 100ms interval between each. Adjacent screenshots are compared pixel-by-pixel. Before this comparison, the screenshots are processed into grayscale images and converted to black and white. If the difference in grayscale values ​​between two corresponding pixels in two adjacent sets of screenshots is greater than a preset value, the pixel is determined to be dynamic. Pixels and dynamic pixels form a dynamic region. If the position of the dynamic region remains unchanged in multiple screenshots, content recognition is performed on the corresponding position of each screenshot corresponding to the dynamic region. If the content recognition results are consistent, the content recognition result is used as the content of the dynamic region, and the dynamic region is filled with the corresponding content recognition result. If the content recognition results are inconsistent, the dynamic region is discarded, and the dynamic region is filled with a preset background. When no more dynamic regions with undetermined content appear in the screenshot, the current page is considered to have completed the screenshot, and the screenshot to be recognized is obtained. Then, switch to the next page and repeat the above steps.

[0083] The OCR recognition module 200 is used to perform OCR recognition on the screenshot to be recognized, obtain the OCR recognition result, and perform preliminary correction on the OCR recognition result through natural language processing algorithm to obtain the text to be verified. The OCR recognition result records the position information of each character.

[0084] In this system, the OCR recognition module 200 performs OCR recognition on the screenshot to be recognized. The screenshot is imported into the preset OCR recognition engine. If the image size of the screenshot is too large, it can be segmented. After being imported into the OCR recognition engine, the corresponding recognition results will be generated. During the OCR recognition process, the position information and font information of each character in the screenshot to be recognized are extracted and recorded in the OCR recognition result. The OCR recognition result is corrected by natural language processing algorithms. The process includes text cleaning of the OCR recognition result to remove noise data, such as spaces and garbled characters. Data verification and optimization are performed by natural language processing algorithms, such as performing logical consistency checks to ensure data accuracy, for example, verifying whether "invoice amount" is a number or whether "date" conforms to the format. After processing, the text in the entire screenshot to be recognized has been extracted. However, inaccurate recognition is inevitable in both OCR recognition and natural language processing. After correction by natural language processing algorithms, the text to be verified is obtained.

[0085] The difference graph extraction module 300 is used to construct a result verification image, mark the text to be verified in the result verification image according to the OCR recognition result, compare it with the screenshot to be recognized, and extract the difference area image.

[0086] In this system, the difference graph extraction module 300 constructs a result verification image. To determine the accuracy of the OCR recognition result, a set of result verification images is constructed. The result verification image has exactly the same size as the screenshot to be recognized, both have the same number of pixels, and the number of pixels in the length and width directions is also the same. The result verification image is a blank image when generated. The background of the screenshot to be recognized is identified, and the result verification image is filled with this background. Texts are extracted one by one from the text to be verified, and the corresponding position information, font information, etc. of the text are extracted from the OCR recognition result, so as to generate corresponding text images, which are overlaid on the result verification image according to their positions to obtain a complete result verification image. The processed result verification image is compared with the screenshot to be recognized pixel by pixel, and the position where there is a difference is determined according to the coincidence relationship between the two. This position is the difference area, and the local image of this position is extracted from the screenshot to be recognized to obtain the difference area image.

[0087] The local correction module 400 is used to magnify a local position of the website, obtain a locally magnified screenshot and perform OCR recognition, adjust the difference area image, and perform comparison again. When the coincidence degree reaches the preset value, the website information collection result is output.

[0088] In this system, the local correction module 400 magnifies a local position of the website. During the process of obtaining the screenshot to be recognized, in order to ensure the recognition efficiency, the scaling method is used to increase the information volume contained in the screenshot to be recognized. When the information volume is large, the clarity of the text will be correspondingly reduced. The web page is magnified according to the difference area to increase the display area of the difference area, and a locally magnified screenshot is obtained again by taking a screenshot, so as to re-perform OCR recognition on the unclear parts in the initial recognition process, and determine different recognition results for each character. For example, when a character at a certain position is recognized by OCR, there are multiple possibilities, such as "工", "土", "士", and "王". When recognizing, the matching degrees of "工", "土", "士", and "王" are 80%, 75%, 91%, and 89% respectively. Then, a corresponding comparison image is generated according to the locally magnified screenshot, the two are compared, the coincidence degree between the two is calculated, and the accuracy of different recognition results is determined according to the coincidence degree, so as to determine the recognition result of each character in the screenshot to be recognized to generate the website information collection result. If the coincidence degree does not meet the preset value, the corresponding character is recorded in the form of a screenshot.

[0089] Such as Figure 6As shown, in a preferred embodiment of the present invention, the OCR recognition module 200 includes:

[0090] The text recognition unit 201 is used to import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result.

[0091] In this module, the text recognition unit 201 imports the screenshot to be recognized into the OCR recognition engine. The OCR recognition engine can be PaddleOCR, Tesseract OCR, or RapidOCR, and the corresponding OCR recognition result is generated through recognition. Alternatively, multiple OCR recognition engines can be used simultaneously, and the recognition results of different OCR recognition engines can be integrated to obtain the final OCR recognition result.

[0092] The text information recording unit 202 is used to extract the position information of each character during the recognition process. The position information is represented by the coordinates of pixels, with the pixel at the center of the character as the position of the character, and the font information of the character is recorded.

[0093] In this module, the text information recording unit 202 extracts the position information of each character during the recognition process. For example, when recognizing a certain character, a selection box is constructed, and the character is selected by the selection box. The center position of the character in the selection box is taken as the position of the character. Specifically, a two-dimensional coordinate system is constructed based on the screenshot to be recognized to determine the position of each pixel. The position of the character is recorded accordingly, and the font information of the character is also recorded.

[0094] The result correction unit 203 is used to import the OCR recognition result into the natural language processing engine, correct the OCR recognition result, and form the text to be verified.

[0095] In this module, the result correction unit 203 imports the OCR recognition result into the natural language processing engine, and uses the context association analysis function, semantic error correction and completion and domain-specific language understanding in the natural language processing engine to process the OCR recognition result to form the text to be verified.

[0096] like Figure 7 As shown, in a preferred embodiment of the present invention, the difference image extraction module 300 includes:

[0097] The verification image generation unit 301 is used to extract information from the screenshot to be recognized, extract the resolution of the screenshot to be recognized, and construct a result verification image with the same size and resolution as the screenshot to be recognized. The result verification image and the screenshot to be recognized use the same background color.

[0098] In this module, the verification image generation unit 301 extracts information from the screenshot to be recognized and generates a set of blank images. The number of pixels contained in the blank images is exactly the same as that in the screenshot to be recognized, that is, the screenshot to be recognized and the blank images contain the same number of pixels in the length and width directions. The background is extracted from the screenshot to be recognized and used to fill the blank images to obtain the result verification image.

[0099] The image reconstruction unit 302 is used to extract each character, font information and corresponding position information from the OCR recognition result, generate corresponding text images, and overlay them on the result verification image.

[0100] In this module, the image reconstruction unit 302 extracts each character, font information, and corresponding position information from the OCR recognition result one by one. According to the order of text recognition, it extracts each character one by one and simultaneously retrieves the font information and position information of the character. The character is then copied into the result verification image. If the text recognition result is accurate, the character reflected in the result verification image will also be the same. A text image corresponding to the character is generated based on the character, font, and position, and the text image is overlaid on the corresponding position in the result verification image.

[0101] The difference recognition unit 303 is used to extract the character block images between the result verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

[0102] In this module, the difference recognition unit 303 extracts character block images between the text in the result verification image and the screenshot to be recognized. Based on the position of the text, it extracts two sets of character block images from the same position in the result verification image and the screenshot to be recognized. The two sets of character block images are respectively from the result verification image and the screenshot to be recognized. The pixels are compared one by one, and the number of duplicate pixels is counted. If the difference between two pixels at the same position in the two sets of character block images is within a preset range, the pixel is determined to be duplicated. The proportion of duplicate pixels is then counted. If the proportion of duplicate pixels is less than a preset value, the area corresponding to the text is determined to be a difference area. A selection area of ​​a preset size is constructed to select the difference area, thereby extracting the corresponding difference area image from the screenshot to be recognized.

[0103] like Figure 8 As shown, in a preferred embodiment of the present invention, the local correction module 400 includes:

[0104] The local recognition unit 401 is used to scale the corresponding position of the website according to the difference region image, take a screenshot of the region to obtain a local magnified image, and perform OCR recognition on the local magnified image to obtain the local recognition result.

[0105] In this module, the local recognition unit 401 scales the corresponding position of the website according to the difference region image. Based on the center of the difference region image, it scales the corresponding position of the website so that the position of the difference region image is magnified. Then, it takes another screenshot to obtain a local magnified image. OCR recognition is performed on the local magnified image to obtain the local recognition result.

[0106] The overlap calculation unit 402 is used to generate multiple sets of images to be compared based on the local recognition results, repeatedly compare the images to be compared with the images of the difference regions, and calculate the similarity.

[0107] The result output unit 403 is used to determine that the text correction is complete and output the website information collection results when the overlap reaches a preset value.

[0108] In this module, the OCR recognition results provide multiple options for each recognition region. A natural language processing engine then predicts the text within the difference regions, yielding multiple prediction results. For example, if text A is within a difference region, and the OCR recognition results provide three possible text options with an accuracy greater than 80%, the natural language processing engine predicts two additional possible text options for text A. Therefore, the region corresponding to text A contains five possible text options. Based on this, the possible text options for each difference region are determined. These options are then combined to obtain multiple combinations. A set of comparison images is generated based on each combination. The text is determined according to the corresponding combination method. Similarly, the pixels in the image to be compared and the image of the difference area are counted. The region where each character is located is compared separately, and its similarity is calculated. If the similarity meets the requirements, the recognition is considered successful. Otherwise, the text screenshot of the corresponding region in the screenshot to be recognized is used as the accurate recognition result of the character, the region is marked, and the website information collection result is output. By enlarging the recognition of inaccurate regions and traversing all selectable characters, the accuracy of text recognition is intuitively verified by image comparison. Inaccurate positions are re-checked, which greatly improves the accuracy of website information collection and ensures the quality of data.

[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for automated collection of website information based on OCR and natural language processing, characterized in that, The method includes: According to the data collection task, access the corresponding website, take a screenshot of the screen displayed on the website, preprocess the screenshot to obtain the screenshot to be identified; The screenshot to be recognized is subjected to OCR recognition to obtain the OCR recognition result. The OCR recognition result is initially corrected by natural language processing algorithm to obtain the text to be verified. The position information of each character is recorded in the OCR recognition result. Construct a result verification image, mark the text to be verified in the result verification image according to the OCR recognition result, compare it with the screenshot to be recognized, and extract the difference area image; The website's local area is magnified to obtain a local magnified screenshot, which is then subjected to OCR recognition. The images of the different areas are adjusted and re-compared. When the overlap reaches a preset value, the website information collection results are output.

2. The automated website information collection method based on OCR and natural language processing according to claim 1, characterized in that, The steps of performing OCR recognition on the screenshot to be recognized, obtaining the OCR recognition result, and then using a natural language processing algorithm to initially correct the OCR recognition result to obtain the text to be verified specifically include: Import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result; During the recognition process, the position information of each character is extracted. The position information is represented by the coordinates of pixels. The pixel at the center of the character is used as the position of the character, and the font information of the character is recorded. The OCR recognition results are imported into the natural language processing engine to correct the OCR recognition results and form the text to be verified.

3. The automated website information collection method based on OCR and natural language processing according to claim 1, characterized in that, The steps of constructing a verification image, marking the text to be verified in the verification image based on the OCR recognition result, comparing it with the screenshot to be recognized, and extracting the difference region image include: Information is extracted from the screenshot to be recognized, including its resolution. A verification image with the same size and resolution as the screenshot to be recognized is constructed, and the verification image and the screenshot to be recognized use the same background color. Extract each character, font information, and corresponding position information from the OCR recognition results, generate corresponding text images, and overlay them on the result verification image; Extract the character block images between the verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

4. The automated website information collection method based on OCR and natural language processing according to claim 1, characterized in that, The steps of magnifying a local area of ​​the website to obtain a magnified screenshot and performing OCR recognition, adjusting the image of the difference area, re-comparing, and outputting the website information collection result when the overlap reaches a preset value, specifically include: The website's corresponding location is scaled based on the image of the difference region, and a screenshot of that region is taken to obtain a local magnified image. OCR recognition is then performed on the local magnified image to obtain the local recognition result. Based on the local recognition results, multiple sets of images to be compared are generated. The images to be compared are repeatedly compared with the images of the difference regions, and the similarity is calculated. When the overlap reaches a preset value, the text correction is deemed complete, and the website information collection results are output.

5. The automated website information collection method based on OCR and natural language processing according to claim 1, characterized in that, In the steps of accessing the corresponding website according to the collection task, taking screenshots of the screen displayed on the website, preprocessing the screenshots to obtain the screenshots to be identified, after accessing the website, taking screenshots at preset time intervals, comparing adjacent screenshots, identifying dynamic and static areas in the screenshots, continuously identifying dynamic areas, discarding dynamic areas if the identification results are different, and retaining them if the identification results are the same.

6. An automated website information collection system based on OCR and natural language processing, characterized in that, The system includes: The website screenshot module is used to access the corresponding website according to the data collection task, take screenshots of the screen displayed on the website, preprocess the screenshots, and obtain the screenshots to be recognized. The OCR recognition module is used to perform OCR recognition on the screenshot to obtain the OCR recognition result. The OCR recognition result is initially corrected by natural language processing algorithm to obtain the text to be verified. The OCR recognition result records the position information of each character. The difference image extraction module is used to construct the result verification image. Based on the OCR recognition result, the text to be verified is marked in the result verification image, and it is compared with the screenshot to be recognized to extract the difference area image. The local correction module is used to magnify a local area of ​​the website, obtain a magnified screenshot, perform OCR recognition, adjust the image of the difference area, and re-compare. When the overlap reaches a preset value, the website information collection result is output.

7. The automated website information collection system based on OCR and natural language processing according to claim 6, characterized in that, The OCR recognition module includes: The text recognition unit is used to import the screenshot to be recognized into the OCR recognition engine, extract the text content through OCR recognition, and obtain the OCR recognition result. The text information recording unit is used to extract the position information of each character during the recognition process. The position information is represented by the coordinates of pixels, with the pixel at the center of the character as the position of the character, and the font information of the character is recorded. The result correction unit is used to import the OCR recognition result into the natural language processing engine, correct the OCR recognition result, and form the text to be verified.

8. The automated website information collection system based on OCR and natural language processing according to claim 6, characterized in that, The difference image extraction module includes: The verification image generation unit is used to extract information from the screenshot to be recognized, extract the resolution of the screenshot to be recognized, and construct a result verification image with the same size and resolution as the screenshot to be recognized. The result verification image and the screenshot to be recognized use the same background color. The image reconstruction unit is used to extract each character, font information and corresponding position information from the OCR recognition result, generate the corresponding text image, and overlay it on the result verification image. The difference recognition unit is used to extract the character block images between the result verification image and the text in the screenshot to be recognized, calculate the similarity, determine the difference region based on the similarity, and extract the difference region image.

9. The website information automated collection system based on OCR and natural language processing according to claim 6, characterized in that, The local correction module includes: The local recognition unit is used to scale the corresponding location of the website based on the image of the difference region, take a screenshot of the region to obtain a local magnified image, and perform OCR recognition on the local magnified image to obtain the local recognition result. The overlap calculation unit is used to generate multiple sets of images to be compared based on the local recognition results, repeatedly compare the images to be compared with the images of the difference regions, and calculate the similarity. The result output unit is used to determine that text correction is complete and output the website information collection results when the overlap reaches a preset value.

10. The automated website information collection system based on OCR and natural language processing according to claim 6, characterized in that, In the steps of accessing the corresponding website according to the collection task, taking screenshots of the screen displayed on the website, preprocessing the screenshots to obtain the screenshots to be identified, after accessing the website, taking screenshots at preset time intervals, comparing adjacent screenshots, identifying dynamic and static areas in the screenshots, continuously identifying dynamic areas, discarding dynamic areas if the identification results are different, and retaining them if the identification results are the same.