Template website key source code fragment identification method
By constructing a website relevance and universality dimensional index system and a machine learning model, the key source code fragments of the template website are extracted, which solves the problems of high resource occupation, slow calculation and limited adaptability in the existing technology, and realizes a fast and efficient template website. identification, reducing resource consumption.
Patent Information
- Application Number
- CN202410768709.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-06-14
AI Technical Summary
Existing template website identification methods have problems such as high resource usage, slow calculation process, limited adaptability and possible misjudgment, making it difficult to quickly and accurately identify different types of template websites.
By collecting the web page source code of known sample websites, we build a website relevance and universality dimensional index system, extract the key source code fragments of the website based on the machine learning model, use UserAgent to obtain the page source code, and parse and extract HTML, JS, CSS, and IMG fragments , construct feature dimensions and form a decision tree model for identification.
Without mastering a large number of samples, it can quickly match and identify template websites for a large number of websites and source codes, improve the identification efficiency, reduce the consumption of computing power, and provide a fast and efficient matching monitoring method, which is especially suitable for black and gray products. Identification of template websites.
Smart Images

Figure CN118796264A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of template website discovery, and in particular to a method for identifying key source code fragments of a template website. Background Art
[0002] Most of the current analysis methods for identifying key source code fragments of template websites are based on content similarity, source code similarity, feature extraction and matching, etc. These methods can effectively identify template websites to a certain extent, but they also have some problems, such as occupying a lot of resources and slow calculation process.
[0003] With the continuous development of technology, some new technologies and methods are constantly emerging. For example, deep learning technology can be used to identify and analyze template websites. By training a large amount of template website data, a more accurate and efficient model can be obtained. In addition, some methods based on semantic understanding and natural language processing can also be used to analyze template websites. Through the semantic understanding and analysis of website content, the characteristics and patterns of template websites can be more accurately identified. The methods are usually as follows:
[0004] 1. Code architecture: The file architecture of a template-based website may be larger because it needs to adapt to various functional requirements, while the code for a customized website will be more concise.
[0005] 2. Web page source files: Simple web pages with complex codes, or strange and useless pictures in the website space may indicate that the website is built using a template.
[0006] 3. Comparison of similar templates: If you see that two websites have the same structure except for the content, have no independence, and are very similar, they may be using the same template.
[0007] 4. Similar content: Template websites usually have the same or largely similar content. Based on text content analysis, it is possible to identify whether two websites are template websites.
[0008] For example, the application number "CN112989341A"; "A method, system and process for analyzing fraudulent websites" relates to the field of Internet domain name technology, specifically, to a method for analyzing fraudulent websites. The method includes obtaining and saving the IP address of a domain name, extracting the IP address of the fraudulent domain name from a list of fraudulent domain names, querying domain names with the same or similar IP addresses as the fraudulent domain name from a saved IP address, generating an analysis task, and analyzing the website and website content corresponding to the domain name based on the set judgment rules to determine whether it is a fraudulent website.
[0009] This technology is mainly used to analyze fraudulent websites and may not be applicable to other types of website analysis. In addition, when faced with a large number of domain names and complex network environments, there may be challenges in terms of efficiency and accuracy. (1) It consumes a lot of resources: When obtaining and analyzing a large number of domain names and website information, it may consume a lot of computing resources and storage resources.
[0010] (2) Slow calculation process: Analysis and judgment based on set judgment rules may make the entire analysis process relatively slow and unable to meet the needs of quickly identifying template websites.
[0011] (3) Limited adaptability: It mainly analyzes fraudulent websites and may not be adaptable enough to other types of template websites, and cannot accurately identify different types of template websites.
[0012] (4) Possible misjudgment: In a complex network environment, there may be certain errors in the judgment of the website, resulting in misjudgment.
[0013] Therefore, in order to solve the above problems, a method for identifying key source code fragments of template websites is needed. Summary of the invention
[0014] The purpose of the present invention is to provide a method for identifying key source code fragments of template websites. The present invention collects web page source codes of known sample websites, constructs a website relevance and universality dimension indicator system, and extracts key source code fragments of websites based on a machine learning model. Based on the recognition results, it is possible to support rapid matching and identification of template websites for a large number of websites and source codes without mastering a large number of samples, greatly improving recognition efficiency and reducing computing power consumption.
[0015] The present invention is achieved in that:
[0016] The present invention provides a method for identifying key source code fragments of a template website, which is specifically performed according to the following steps:
[0017] S 1 : Based on the two UserAgents of PC and mobile, the page source code of the website is obtained, and external link resources such as pictures and files are obtained; after obtaining the complete webpage source code information, the HTML, JS, CSS, IMG fragments or files are obtained by constructing the extraction rules of source code files and source code fragments; obtaining the page source code of the website is specifically to directly send a request to the target website to obtain the source code of the page, and the obtained source code is the original structure of the website's open source code;
[0018] Alternatively, the website is accessed through browser rendering to obtain the source code structure of the website after it is completely loaded, wherein the source code structure includes pictures and data content information; after the website source code is loaded, the source code of the website is parsed to obtain the resource file information associated with the website.
[0019] The extraction rules for constructing source code files and source code fragments specifically include aggregating and removing duplicates of the collected website source codes, extracting page html, meta, style, script, link, and img specific tags by parsing the page code, extracting the current code fragments from html, meta, style, part of the script, and img built-in content tags for storage; for tags with link, part of the script, and img external link file properties, the src and href file link attributes must be obtained, and the file corresponding to the link must be obtained for storage; the collected website links, file links, code fragments, and code type information are formatted and stored to form raw data that supports subsequent key source code analysis.
[0020] S 2 : Based on manual analysis, an indicator system for evaluating the relevance and universality of source code is formed, and a batch of positive and negative samples are manually annotated;
[0021] S 3 : Based on machine learning models, training is performed to form a model for analyzing key source code fragments of the website;
[0022] Model construction includes indicator dimension construction and analysis; it is specifically carried out in the following steps:
[0023] S 3.1 :Build feature dimensions based on the universality and relevance of source code, and build an analysis sample library based on the original data of key source code analysis; the universality dimension identifies common source code and content on the Internet, including Baidu Statistics and Google Statistics universal third-party libraries. The uniqueness dimension is used to identify source code and content unique to the current template website, usually combined with its business keywords and data request behavior characteristics of the website background.
[0024] S 3.2 :The data used for universal analysis specifically includes CDN domain name, third-party library / SDK and simple universal code. The correlation index analysis includes the acquired source code, images and text. The source code includes the data request and initialization function of the same domain on the website. The image includes the LOGO, and the text includes business keywords.
[0025] S 4 : Analyze the real-time source code fragment data through the model and output the analysis results.
[0026] Label the existing dimensions of the system, and after labeling is completed, it is submitted to manual review and annotation to form positive and negative samples. After completion, the machine learning decision tree model is used for training to form an analysis model; as shown in formula (1)-formula (2);
[0027]
[0028] Among them, H(D) represents the uncertainty of data set D, P(c_i) is the proportion of category c_i in data set D;
[0029] R α (T) = R (T) + α | T | Formula (2)
[0030] Among them, R(T) is the error of decision tree T for training data, |T| is the number of leaf nodes in the tree, and α is the regularization parameter used to balance model complexity and error.
[0031] The indicator dimensions are shown in Table 1;
[0032] Table 1 Indicator dimension table
[0033]
[0034] Furthermore, the present invention provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a main controller, the method described in any one of the above is implemented.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] 1. By collecting the webpage source code of known sample websites, building a website relevance and universality dimension indicator system, and extracting the key source code fragments of the website based on the machine learning model. Based on the recognition results, it can support the rapid matching and identification of template websites for a large number of websites and source codes without mastering a large number of samples, greatly improving the recognition efficiency and reducing computing power consumption. It can provide a fast and efficient matching monitoring method in the field of template website discovery, especially in the identification of template websites of black and gray industries, greatly reducing the resource consumption of the analysis process. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It is understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 is a flow chart of the method of the present invention;
[0039] Figure 2 It is a flow chart of indicator dimension construction and analysis of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but is only for selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0041] See also Figure 1-2 The present invention provides a method for identifying key source code fragments of a template website, which is specifically performed in the following steps:
[0042] Please follow the steps below:
[0043] S 1 : Based on the two UserAgents of PC and mobile, the page source code of the website is obtained, and external link resources such as pictures and files are obtained; after obtaining the complete webpage source code information, the HTML, JS, CSS, IMG fragments or files are obtained by constructing the extraction rules of source code files and source code fragments; obtaining the page source code of the website is specifically to directly send a request to the target website to obtain the source code of the page, and the obtained source code is the original structure of the website's open source code;
[0044] Alternatively, the website is accessed through browser rendering to obtain the source code structure of the website after it is completely loaded, wherein the source code structure includes pictures and data content information; after the website source code is loaded, the source code of the website is parsed to obtain the resource file information associated with the website.
[0045] The extraction rules for constructing source code files and source code fragments specifically include aggregating and removing duplicates of the collected website source codes, extracting page html, meta, style, script, link, and img specific tags by parsing the page code, extracting the current code fragments from the html, meta, style, part of the script, and img built-in content tags for storage; for the link, part of the script, and img external link file tags, the src and href file link attributes must be obtained, and the file corresponding to the link must be obtained for storage; the collected website links, file links, code fragments, and code type information are formatted and stored to form raw data that supports subsequent key source code analysis.
[0046] S2 : Based on manual analysis, an indicator system for evaluating the relevance and universality of source code is formed, and a batch of positive and negative samples are manually annotated;
[0047] S 3 : Based on machine learning models, training is performed to form a model for analyzing key source code fragments of the website;
[0048] Model construction includes indicator dimension construction and analysis; it is specifically carried out in the following steps:
[0049] S 3.1 :Build feature dimensions based on the universality and relevance of source code, and build an analysis sample library based on the original data of key source code analysis; the universality dimension identifies common source code and content on the Internet, including Baidu Statistics and Google Statistics universal third-party libraries. The uniqueness dimension is used to identify source code and content unique to the current template website, usually combined with its business keywords and data request behavior characteristics of the website background.
[0050] S 3.2 :The data used for universal analysis specifically includes CDN domain name, third-party library / SDK and simple universal code. The correlation index analysis includes the acquired source code, images and text. The source code includes the data request and initialization function of the same domain on the website. The image includes the LOGO, and the text includes business keywords.
[0051] S 4 : Analyze the real-time source code fragment data through the model and output the analysis results.
[0052] Label the existing dimensions of the system, and after labeling is completed, it is submitted to manual review and annotation to form positive and negative samples. After completion, the machine learning decision tree model is used for training to form an analysis model; as shown in formula (1)-formula (2);
[0053]
[0054] Among them, H(D) represents the uncertainty of data set D, P(c_i) is the proportion of category c_i in data set D;
[0055] R α (T) = R (T) + α | T | Formula (2)
[0056] Among them, R(T) is the error of decision tree T for training data, |T| is the number of leaf nodes in the tree, and α is the regularization parameter used to balance model complexity and error.
[0057] The indicator dimensions are shown in Table 1;
[0058] Table 1 Indicator dimension table
[0059] Indicator name type illustrate Condition Type external_link_address domain name Is it an external link address? cdn_domain domain name Is it a CDN domain name? Negative sdk_name_hit SDK Whether to hit SDK Negative generic_minimal_code Code Is the code minimalist? Negative business_word_hit_status text Business word hits has_network_communication_behavior Code Same domain data request Has_initial_code Code Initialization function tab_ico_icon image Is it a LOGO?
[0060] In this embodiment, the original URL data is prepared and collected, and a batch of website source code files that meet the expected business type are prepared through active discovery on the Internet, and the website source code files can also be obtained through collection. Associated resource collection. The web page structure is analyzed to obtain the associated external link file materials of the website, including pictures, external link JavaScript files, and external link CSS files, and download calculations are performed based on http requests.
[0061] In this embodiment, website source code fragments are extracted;
[0062] Based on XML structure analysis, the content tags and code snippets of the website are obtained for storage, such as html, meta, style, partial script, img, etc.; for tags with external link file properties such as link, partial script, img, etc., the file link attributes such as src and href need to be obtained, and the file corresponding to the link is obtained for storage.
[0063] In this embodiment, a method for analyzing universality index and uniqueness index is constructed.
[0064] Filter items:
[0065] A: CDN domain name resources: Build a CDN domain name list to identify whether the loading source of the external link resource file is the CDN service.
[0066] B: Third-party library / SDK identification: Build an SDK matching rule list, including name, HASH, etc., and detect resources such as JS / CSS / IMG.
[0067] C: General minimalist code recognition: reset, jump and other codes in javascript code, such as window.localtion="", window.baseUrl="", etc.
[0068] Identification Item:
[0069] The source code can identify the data request and initialization function of the same domain, which is implemented as follows:
[0070] D: Same-domain data request: Analyze JS files and code snippets, identify network request behaviors by calling network request methods, obtain the host that accesses the network, and detect whether it is a same-domain host or domain name.
[0071] E: Initialization function: In some template websites for specific businesses, there may be some codes for loading configuration, initialization and other functions, which can be identified based on the form and parameters of the code;
[0072] Build business keywords and analyze website source code based on keywords.
[0073] F: Business keyword analysis: Analyze the hot words and related words through the contents of a batch of common business websites, summarize them into business keywords, and use them as matching items when analyzing the target website.
[0074] In terms of images, the website's LOGO, ICON and other image resources can be identified
[0075] G: LOGO: Based on the alt, class, id and other attributes of the source code, obtain surrounding reference content for analysis to identify whether the image is a LOGO.
[0076] In this embodiment, the indicator item data is marked
[0077] Based on the expert review method, the nature of each source code is identified and judged to determine whether it is a key source code fragment; sample data for model training is formed.
[0078] In this embodiment, model analysis is performed;
[0079] The manually annotated and verified positive and negative samples are respectively input into the machine learning model for learning to form a website key source code fragment recognition model
[0080] In this embodiment, the present invention provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a main controller, the method described in any one of the above is implemented.
[0081] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention has various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for identifying key source code fragments of a template website, Features: Please follow the steps below: S 1 : Based on the two UserAgents of PC and mobile, the page source code of the website is obtained, and external link resources such as pictures and files are obtained; after obtaining the complete web page source code information, the HTML, JS, CSS, IMG fragments or files are obtained by constructing the extraction rules of source code files and source code fragments; S 2 : Based on manual analysis, an indicator system for evaluating the relevance and universality of source code is formed, and a batch of positive and negative samples are manually annotated; S 3 : Based on machine learning models, training is performed to form a model for analyzing key source code fragments of the website; S 4 : Analyze the real-time source code fragment data through the model and output the analysis results.
2. A method for identifying key source code fragments of a template website according to claim 1, It is characterized in that In step S 1 In the method, obtaining the page source code of the website specifically includes directly sending a request to the target website to obtain the source code of the page, and the obtained source code is the original structure of the website's open source code; Alternatively, the website is accessed through browser rendering to obtain the source code structure of the website after it is completely loaded, wherein the source code structure includes pictures and data content information; after the website source code is loaded, the source code of the website is parsed to obtain the resource file information associated with the website.
3. A method for identifying key source code fragments of a template website according to claim 1, Features: In step S 1 In the process, the extraction rules for constructing source code files and source code fragments specifically include aggregating and removing duplicates of the collected website source codes, extracting page html, meta, style, script, link, and img specific tags by parsing the page code, extracting the current code fragments from the html, meta, style, part of the script, and img built-in content tags for storage; obtaining the src and href file link attributes for the link, part of the script, and img external link file tags, and obtaining the file corresponding to the link for storage; formatting and storing the collected website links, file links, code fragments, and code type information to form raw data that supports subsequent key source code analysis.
4. A method for identifying key source code fragments of a template website according to claim 1, Features: In step S 3 In the model construction, the indicator dimension construction and analysis are included; the specific steps are as follows: S 3.1 : Construct feature dimensions based on the universality and relevance of source code, and build an analysis sample library based on the original data of key source code analysis; S 3.2 :The data used for universal analysis specifically includes CDN domain name, third-party library / SDK and simple universal code. The correlation index analysis includes the acquired source code, images and text. The source code includes the data request and initialization function of the same domain on the website. The image includes the LOGO, and the text includes business keywords.
5. A method for identifying key source code fragments of a template website according to claim 1, Features: In step S 4 In the process, the existing dimensions of the system are labeled. After the labeling is completed, they are submitted to manual review and annotation to form positive and negative samples. After completion, the machine learning decision tree model is used for training to form an analysis model; as shown in formula (1)-formula (2); Among them, H(D) represents the uncertainty of data set D, P(c_i) is the proportion of category c_i in data set D; R α (T) = R(T) + α|T| Equation (2) Among them, R(T) is the error of decision tree T for training data, |T| is the number of leaf nodes in the tree, and α is the regularization parameter used to balance model complexity and error.
6. A method for identifying key source code fragments of a template website according to claim 4, Features: In step S 3.1 The universal dimension identifies common source code and content on the Internet, including Baidu Statistics and Google Statistics universal third-party libraries.
7. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by the main controller, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and system for determining fraud-related webpage and medium
CN112989341A
Method for establishing machine learning model to check webpage hidden links through domain identification and theme identification
CN107566391A
Dark network data collection and extraction system and method
CN107808000A
Complete-website-source-code acquisition method and illegal-website detection method and system
CN107957872A
Illegal website identification method and device, electronic equipment and readable storage medium
CN115766167A
Cited By
Intelligent OCR (Optical Character Recognition) channel selection method and device for character recognition, equipment and medium
CN121170823A
