A webpage link updating method, device, equipment and medium
By automatically updating webpage links to redirect to alternative domain addresses when a website is subjected to DNS hijacking, the problem of links failing to redirect normally is solved, ensuring the integrity and availability of the system and simplifying the processing flow.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2026-03-24
AI Technical Summary
When a website is subjected to DNS hijacking, accessing the website through an alternative domain name results in page links failing to redirect properly, causing some functions to become unavailable. Existing technical solutions are complex and require system upgrades and program recompilation.
When the domain name corresponding to the current webpage is detected as an alternate domain name, the target element is identified, the target link is found based on the domain name mapping relationship, and the link to be updated in the current webpage is updated, so as to automatically redirect to the alternate domain name address.
It enables automatic updates of webpage links after a website domain is attacked, ensuring the complete availability of the system without the need for system upgrades or program recompilation.
Smart Images

Figure CN115344801B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of web page development technology, and in particular to a method, apparatus, device, and medium for updating web page links. Background Technology
[0002] When a user visits a website, they first need to enter the website's domain name in their browser. The domain name resolution server then resolves the domain name to the corresponding IP address, allowing the user to access the website's server and finally display the content in the browser. However, when a website suffers DNS hijacking, the domain name resolution server cannot resolve the correct IP address, preventing users from accessing the website. In this case, the website can continue to provide services using an alternative domain name, but the links on the website will remain unchanged.
[0003] Current technologies involve resolving multiple domain names to the same IP address or using redirection to achieve simultaneous service from primary and backup domains. Alternatively, domain links are processed on the server side, and the processed content is sent to the front end for display. However, since the links on pages accessed through the primary and backup domains are identical, if these links are not adjusted and are also affected, it can lead to the unavailability of some website functions. Processing domain links on the server side requires completing the process on the server itself, and system upgrades and configuration adjustments necessitate recompiling the program, making the process complex. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for updating web page links, so that when a user accesses a website through an alternative domain name, clicking a link on the page can automatically redirect to the corresponding alternative domain name address, thereby ensuring the integrity and availability of the system.
[0005] According to one aspect of the present invention, a method for updating a webpage link is provided, the method comprising:
[0006] When it is detected that the domain name corresponding to the current webpage is an alternate domain name, the target element in the current webpage is determined;
[0007] Based on the target element, the link to be updated in the current webpage is determined, and based on the domain name mapping relationship, the target link corresponding to the link to be updated is found; wherein, the target element corresponds to the link to be updated;
[0008] The links to be updated in the current webpage are updated based on the target link to obtain the target webpage.
[0009] According to another aspect of the present invention, a webpage link updating device is provided, the device comprising:
[0010] The target element determination module is used to determine the target element in the current webpage when it is detected that the domain name corresponding to the current webpage is an alternate domain name;
[0011] The target link determination module is used to determine the link to be updated in the current webpage based on the target element, and to find the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated;
[0012] The target webpage generation module is used to update the links to be updated in the current webpage based on the target link, so as to obtain the target webpage.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] At least one processor; and
[0015] A memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the webpage link update method according to any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the webpage link update method according to any embodiment of the present invention.
[0018] The technical solution of this invention, when detecting that the domain name corresponding to the current webpage is a backup domain name, determines the target element in the current webpage; determines the link to be updated in the current webpage based on the target element, and finds the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; and updates the link to be updated in the current webpage based on the target link to obtain the target webpage. This solves the technical problem in the prior art where, after a website domain name is attacked, accessing the website through a backup domain name results in the inability to redirect normally when clicking on the links in the webpage. It achieves automatic updating of links in the webpage so that the links on the webpage can redirect to the backup domain name address of the associated system, thereby ensuring the integrity and availability of the system.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 The flowchart illustrates a method for updating webpage links according to Embodiment 1 of the present invention.
[0022] Figure 2 A flowchart illustrating a method for updating web page links according to Embodiment 2 of the present invention;
[0023] Figure 3 This is a schematic diagram of the structure of a webpage link updating device provided in Embodiment 3 of the present invention;
[0024] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] Example 1
[0028] Figure 1This is a flowchart illustrating a webpage link update method according to Embodiment 1 of the present invention. This embodiment is applicable to situations where a website is accessed via an alternate domain name, requiring automatic conversion of links within the webpage. This method can be executed by a website link update device, which can be implemented in hardware and / or software, and can be configured on a PC or mobile terminal. Figure 1 As shown, the method includes:
[0029] S110. When it is detected that the domain name corresponding to the current webpage is an alternate domain name, determine the target element in the current webpage.
[0030] Here, "current webpage" refers to the webpage being accessed. The webpage can be accessed via the main domain or backup domain of the website to which the webpage belongs. "Target element" refers to the HTML element in the webpage, which corresponds to a link.
[0031] Specifically, when a website's main domain is attacked, the corresponding webpage cannot be reached through the main domain. Instead, the webpage can be accessed by entering an alternative domain name in the browser. This alternative domain name is the current webpage, which contains multiple different HTML elements. One or more HTML elements are selected from these elements as the target element.
[0032] Based on the above technical solution, before determining the target element in the current webpage when the domain name corresponding to the current webpage is detected to be an alternate domain name, the method further includes: pre-determining the source code of each webpage and adding a preset attribute to at least one element in the source code to obtain a preset element; determining the preset element corresponding to each webpage and establishing an element list based on the preset element corresponding to each webpage.
[0033] The source code of a webpage refers to the code required for loading various webpages on the website. It can be an HTML file, and at least one element can be an HTML element. A webpage contains multiple different elements. Preset attributes can be custom attributes. Preset elements can be HTML elements with preset attributes added to the webpage. The element list stores the information of the preset elements contained in each webpage.
[0034] Specifically, the source code for each page on the website can be predetermined, and preset attributes can be added to the elements in the source code. This could involve adding a custom attribute `addressTransfer` to HTML elements, indicating that the links within that element need to be processed. Elements with this preset attribute become preset elements, while links to elements without this attribute will remain unchanged. Furthermore, preset attributes can be added to a subset of elements on each webpage, and an element list can be created containing information about the preset elements for each webpage. This allows for easy identification of which elements on a webpage are preset elements and which are not when accessing a particular webpage later.
[0035] Based on the above technical solution, when it is detected that the domain name corresponding to the current webpage is an alternate domain name, determining the target element in the current webpage includes: traversing the source code of the current webpage and determining the element in the source code of the current webpage that is the same as the element list as the target element.
[0036] Specifically, the source code of the current webpage is traversed. The source code contains multiple elements, which can be matched with the elements in the element list. If an element in the source code is the same as an element in the element list, that element can be considered the target element, and the link corresponding to that element needs to be modified.
[0037] S120. Determine the links to be updated in the current webpage based on the target element, and find the target links corresponding to the links to be updated based on the domain name mapping relationship.
[0038] In this context, the target element corresponds to the link to be updated, which refers to the link in the webpage that corresponds to the target element. The target link can be the link that is ultimately determined.
[0039] It's important to note that the current webpage contains one or more links that can be used to access other websites related to this website. For example, if website A is related to website B, clicking a link on the current page of website A will redirect you to a page on website B. Correspondingly, the link corresponding to the target element is the link to be updated. This link is used to access pages on other websites, and the domain mapping relationship represents the mapping between the main domain and the secondary domain of those other websites.
[0040] Specifically, links on the current page corresponding to the target element can be designated as links to be updated. This is because when the website's main domain is attacked, access to the current webpage is via an alternate domain. However, the links on the current webpage will not change; that is, clicking the links to be updated on the current webpage should not redirect to the alternate domain address of the associated website, nor should it switch the current page to a page on the associated website. Therefore, it is necessary to find the target link corresponding to the link to be updated in the domain mapping relationship, and then update the link to be updated. This will allow clicking the updated link on the current webpage to automatically redirect to a page on the associated website.
[0041] Based on the above technical solution, before determining the links to be updated in the current webpage based on the target element and finding the target links corresponding to the links to be updated based on the domain name mapping relationship, the method further includes: determining the main domain name and backup domain name corresponding to each link to be matched in the current webpage; and establishing the domain name mapping relationship based on the main domain name and backup domain name.
[0042] Specifically, the links to be matched refer to the various links on the current webpage. As you can understand, a webpage usually has multiple links, but not all of them need to be updated or modified. In order to quickly determine the alternative domain name of the link to be updated when modification is required, the main domain name and alternative domain name of the associated website corresponding to each link to be matched on the page can be stored in advance and a mapping relationship can be established. When needed, it can be directly searched.
[0043] Based on the above technical solution, the domain name mapping relationship is recorded in the preset form and stored in the target script; the domain name mapping relationship is modified based on the target script.
[0044] The target script can be a JavaScript script used to store the mapping relationship between the main domain name and the backup domain name of the associated website.
[0045] Specifically, the mapping relationship between each primary domain name and its corresponding backup domain name can be recorded in the form of a Map, and the data can be stored in a JavaScript script, which can be added and modified at any time.
[0046] Based on the above technical solution, the step of determining the link to be updated in the current webpage based on the target element and finding the target link corresponding to the link to be updated based on the domain name mapping relationship includes: determining the link to be matched corresponding to the link to be updated based on the link to be updated; determining the backup domain name corresponding to the link to be matched based on the link to be matched and the domain name mapping relationship, so as to determine the backup domain name as the target link of the link to be updated.
[0047] Specifically, when a link needs to be updated, simply look up the matching link in the domain mapping table and use the backup domain corresponding to the matching link as the target link for the update.
[0048] S130. Update the links to be updated in the current webpage based on the target links to obtain the target webpage.
[0049] The target webpage refers to the webpage obtained after updating the link.
[0050] Specifically, after updating the links to be updated on the current webpage based on the target link, the resulting webpage is the target webpage. On the target webpage, users can click on the link to be successfully redirected to other related webpages corresponding to the link.
[0051] Based on the above technical solution, updating the link to be updated in the current webpage based on the target link to obtain the target webpage includes: replacing the link to be updated based on the target link, and determining the current webpage after replacement as the target webpage.
[0052] Specifically, the target link can replace the existing link to be updated on the webpage, and then the current webpage after the replacement can be used as the target webpage.
[0053] The technical solution of this invention, when detecting that the domain name corresponding to the current webpage is a backup domain name, determines the target element in the current webpage; determines the link to be updated in the current webpage based on the target element, and finds the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; and updates the link to be updated in the current webpage based on the target link to obtain the target webpage. This solves the technical problem in the prior art where, after a website domain name is attacked, accessing the website through a backup domain name results in the inability to redirect normally when clicking on the links in the webpage. It achieves automatic updating of links in the webpage so that the links on the webpage can redirect to the backup domain name address of the associated system, thereby ensuring the integrity and availability of the system.
[0054] Example 2
[0055] Figure 2 This is a flowchart illustrating a method for updating webpage links according to Embodiment 2 of the present invention. This embodiment is a preferred embodiment of the above embodiments, and its specific implementation can be found in the technical solution of this embodiment. Technical terms that are the same as or corresponding to those in the above embodiments will not be repeated here. Figure 2 As shown, the method includes:
[0056] Obtain the page's HTML source code; locate elements containing custom attributes; process the links within the custom elements based on domain mapping relationships to generate converted link addresses; replace the original links with the converted links; and allow users to access the converted page.
[0057] The module that executes this method will be explained next:
[0058] (1) Domain Mapping Module
[0059] The domain mapping module records the mapping relationship between each domain name and its alternative domain name in the form of a Map. The data is stored in JavaScript and can be added or modified at any time.
[0060] (2) Element Attributes Module
[0061] To enable automatic link address conversion, a custom attribute `addressTransfer` needs to be added to the HTML element. This attribute indicates that the link address within this element needs to be processed; elements without this attribute will remain unchanged. The element attributes module generates a list of all elements containing this custom attribute for use by the subsequent address conversion module.
[0062] (3) Address translation module
[0063] The address translation module performs a link translation step. First, it determines whether the current domain accessed by the user is an alternative domain. If not, no action is taken. If it is, it iterates through all special attribute elements in the HTML, generates a new link address based on the domain mapping relationship, and replaces the original link address with the new address. At this point, clicking the page link will redirect the user to the translated address.
[0064] The technical solution of this invention, when detecting that the domain name corresponding to the current webpage is a backup domain name, determines the target element in the current webpage; determines the link to be updated in the current webpage based on the target element, and finds the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; and updates the link to be updated in the current webpage based on the target link to obtain the target webpage. This solves the technical problem in the prior art where, after a website domain name is attacked, clicking on links in the webpage cannot redirect normally when accessing the website through a backup domain name. It achieves automatic updating of links in the webpage so that the links on the webpage can redirect to the backup domain name address of the associated system, thereby ensuring the integrity and availability of the system. This solution automatically adjusts the links in the page according to the domain name currently accessed by the user, maintains the consistency of website functionality, has scalability, and can complete the update by modifying JavaScript without recompiling.
[0065] Example 3
[0066] Figure 3 This is a schematic diagram of a webpage link updating device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes:
[0067] The target element determination module 310 is used to determine the target element in the current webpage when it is detected that the domain name corresponding to the current webpage is an alternate domain name;
[0068] The target link determination module 320 is used to determine the link to be updated in the current webpage based on the target element, and to find the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated;
[0069] The target webpage generation module 330 is used to update the links to be updated in the current webpage based on the target links to obtain the target webpage.
[0070] Based on the above-mentioned device, it also includes:
[0071] The preset attribute adding module is used to predetermine the source code of each webpage before determining the target element in the current webpage when the domain name corresponding to the current webpage is detected to be an alternate domain name, and to add a preset attribute to at least one element in the source code to obtain a preset element.
[0072] Determine the preset elements corresponding to each webpage, and create an element list based on the preset elements corresponding to each webpage.
[0073] Based on the above-mentioned device, the target element determination module 310 includes:
[0074] The target element determination unit is used to traverse the source code of the current webpage and determine the elements in the source code of the current webpage that are the same as those in the element list as target elements.
[0075] Based on the above-mentioned device, it also includes:
[0076] The primary and backup domain name determination module is used to determine the primary domain name and backup domain name corresponding to each link to be matched in the current webpage before determining the link to be updated in the current webpage based on the target element and finding the target link corresponding to the link to be updated based on the domain name mapping relationship.
[0077] The domain name relationship establishment module is used to establish the domain name mapping relationship based on the primary domain name and the backup domain name.
[0078] Based on the above-mentioned device, the target link determination module 320 includes:
[0079] The module for determining the link to be matched is used to determine the link to be matched corresponding to the link to be updated based on the link to be updated.
[0080] The target link determination unit is used to determine the backup domain name corresponding to the link to be matched based on the link to be matched and the domain name mapping relationship, so as to determine the backup domain name as the target link of the link to be updated.
[0081] Based on the above-mentioned device, the target webpage generation module 330 includes:
[0082] The link replacement module is used to replace the link to be updated based on the target link, and to determine the current webpage after replacement as the target webpage.
[0083] Based on the above-mentioned device, it also includes:
[0084] A domain name relationship storage module is used to record the domain name mapping relationship based on the preset format and store the domain name mapping relationship in the target script;
[0085] The domain name relationship modification module is used to modify the domain name mapping relationship based on the target script.
[0086] The technical solution of this invention, when detecting that the domain name corresponding to the current webpage is a backup domain name, determines the target element in the current webpage; determines the link to be updated in the current webpage based on the target element, and finds the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; and updates the link to be updated in the current webpage based on the target link to obtain the target webpage. This solves the technical problem in the prior art where, after a website domain name is attacked, accessing the website through a backup domain name results in the inability to redirect normally when clicking on the links in the webpage. It achieves automatic updating of links in the webpage so that the links on the webpage can redirect to the backup domain name address of the associated system, thereby ensuring the integrity and availability of the system.
[0087] The webpage link updating device provided in this embodiment of the invention can execute the webpage link updating method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0088] Example 4
[0089] Figure 4This is a schematic diagram of an electronic device according to Embodiment 4 of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0090] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0091] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0092] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the method of updating web page links.
[0093] In some embodiments, the web link update method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the web link update method described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to perform the web link update method by any other suitable means (e.g., by means of firmware).
[0094] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0095] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0096] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0097] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0098] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0099] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0100] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0101] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for updating webpage links, characterized in that, include: The source code of each webpage is determined in advance, and a preset attribute is added to at least one element in the source code to obtain the preset element; The preset attribute indicates that the link address of the corresponding element needs to be modified; Determine the preset elements corresponding to each webpage, and create an element list based on the preset elements corresponding to each webpage; When it is detected that the domain name corresponding to the current webpage is an alternate domain name, the target element in the current webpage is determined; Based on the target element, the link to be updated in the current webpage is determined, and the target link corresponding to the link to be updated is found based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; the target link is the determined final redirect link; the domain name mapping relationship is the mapping relationship between the main domain name and the backup domain name of other websites; The links to be updated in the current webpage are updated based on the target link to obtain the target webpage; The step of determining the target element in the current webpage when the domain name corresponding to the current webpage is detected to be an alternate domain name includes: Traverse the source code of the current webpage and identify the elements in the source code of the current webpage that are the same as those in the element list as the target elements.
2. The method according to claim 1, characterized in that, Before determining the link to be updated in the current webpage based on the target element and finding the target link corresponding to the link to be updated based on the domain name mapping relationship, the method further includes: Determine the primary domain and backup domain corresponding to each link to be matched in the current webpage; The domain name mapping relationship is established based on the primary domain name and the backup domain name.
3. The method according to claim 2, characterized in that, The step of determining the link to be updated in the current webpage based on the target element, and finding the target link corresponding to the link to be updated based on the domain name mapping relationship, includes: Based on the link to be updated, determine the matching link corresponding to the link to be updated; Based on the link to be matched and the domain name mapping relationship, an alternative domain name corresponding to the link to be matched is determined, so as to determine the alternative domain name as the target link of the link to be updated.
4. The method according to claim 2, characterized in that, The step of updating the links to be updated in the current webpage based on the target link to obtain the target webpage includes: The link to be updated is replaced based on the target link, and the current webpage after replacement is determined as the target webpage.
5. The method according to claim 2, characterized in that, include: The domain name mapping relationship is recorded in a preset format and stored in the target script; The domain name mapping relationship is modified based on the target script.
6. A device for updating webpage links, characterized in that, include: The target element determination module is used to determine the target element in the current webpage when it is detected that the domain name corresponding to the current webpage is an alternate domain name; The target link determination module is used to determine the link to be updated in the current webpage based on the target element, and to find the target link corresponding to the link to be updated based on the domain name mapping relationship; wherein, the target element corresponds to the link to be updated; the target link is the determined final redirect link; and the domain name mapping relationship is the mapping relationship between the main domain name and the backup domain name of other websites; The target webpage generation module is used to update the links to be updated in the current webpage based on the target link, so as to obtain the target webpage; The preset attribute adding module is used to predetermine the source code of each webpage before determining the target element in the current webpage when the domain name corresponding to the current webpage is detected to be an alternate domain name, and add a preset attribute to at least one element in the source code to obtain a preset element; the preset attribute indicates that the link address of the corresponding element needs to be modified; determine the preset element corresponding to each webpage, and establish an element list based on the preset element corresponding to each webpage; The target element determination module is specifically used to traverse the source code of the current webpage and determine the elements in the source code of the current webpage that are the same as those in the element list as target elements.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, which enables the at least one processor to perform the webpage link update method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method for updating web page links according to any one of claims 1-5.
Citation Information
Patent Citations
Page link replacement method and device
CN112560399A