CN111027656B - Two-dimensional code generation and identification method and device, electronic equipment and storage medium - Google Patents

Two-dimensional code generation and identification method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111027656B
CN111027656B CN201911118805.5A CN201911118805A CN111027656B CN 111027656 B CN111027656 B CN 111027656B CN 201911118805 A CN201911118805 A CN 201911118805A CN 111027656 B CN111027656 B CN 111027656B
Authority
CN
China
Prior art keywords
url
short
links
character string
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911118805.5A
Other languages
Chinese (zh)
Other versions
CN111027656A (en
Inventor
张莹
钱鸿强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Koubei Network Technology Co Ltd
Original Assignee
Zhejiang Koubei Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Koubei Network Technology Co Ltd filed Critical Zhejiang Koubei Network Technology Co Ltd
Priority to CN201911118805.5A priority Critical patent/CN111027656B/en
Publication of CN111027656A publication Critical patent/CN111027656A/en
Application granted granted Critical
Publication of CN111027656B publication Critical patent/CN111027656B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/06009Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking
    • G06K19/06037Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code with optically detectable marking multi-dimensional coding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9554Retrieval from the web using information identifiers, e.g. uniform resource locators [URL] by using bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9566URL specific, e.g. using aliases, detecting broken or misspelled links

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Transfer Between Computers (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The specification provides a two-dimensional code generation and identification method, a device, electronic equipment and a storage medium; the generating method may include: obtaining a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string; according to the mapping relation between the pre-configured long character strings and the short character strings, the long character strings contained in the target URL links are replaced by the short character strings, so that the short URL links corresponding to the target URL links are obtained; and generating a two-dimensional code based on the short URL link.

Description

Two-dimensional code generation and identification method and device, electronic equipment and storage medium
Technical Field
One or more embodiments of the present disclosure relate to the field of encoding technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for generating and identifying a two-dimensional code.
Background
The two-dimensional code is a pattern with black and white alternately distributed on a plane (in a two-dimensional direction) according to a certain rule by adopting a specific geometric pattern. The two-dimension code uses the concept of 0 and 1 bit stream forming the logic foundation in the computer ingeniously in code programming, uses a plurality of geometric shapes corresponding to binary system to represent literal numerical information, and then the image input device or the photoelectric scanning device can automatically read the meaning represented by the two-dimension code. In the related art, a URL (Uniform Resource Locator ) link may be converted into a two-dimensional code, thereby facilitating a user to access a network resource corresponding to the URL link by scanning the two-dimensional code.
Disclosure of Invention
In view of this, one or more embodiments of the present disclosure provide a two-dimensional code generating and identifying method, apparatus, electronic device, and storage medium.
In order to achieve the above object, one or more embodiments of the present disclosure provide the following technical solutions:
according to a first aspect of one or more embodiments of the present disclosure, a two-dimensional code generating method is provided, including:
obtaining a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string;
according to the mapping relation between the pre-configured long character strings and the short character strings, the long character strings contained in the target URL links are replaced by the short character strings, so that the short URL links corresponding to the target URL links are obtained;
and generating a two-dimensional code based on the short URL link.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Optionally, the obtaining the target URL link includes:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; or alternatively, the process may be performed,
acquiring the original URL link;
and adopting the URL encoding algorithm to encode each level of sub-links in the original URL link respectively to obtain the target URL link.
Optionally, the URL coding algorithm is adopted to code any one of the separation character strings to obtain a long character string, and the long character string and any one of the separation character strings are in one-to-one correspondence; the mapping relation is one-to-one correspondence relation between the long character strings and the short character strings.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
According to a second aspect of one or more embodiments of the present disclosure, a two-dimensional code identification method is provided, including:
analyzing the target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings;
obtaining a reduction result aiming at the short URL link, and taking the reduction result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Alternatively to this, the method may comprise,
the mapping relation is configured locally; the obtaining the reduction result of the short URL link includes: replacing short character strings contained in the short URL links with long character strings according to the mapping relation configured locally; or alternatively, the process may be performed,
the obtaining the reduction result of the short URL link includes: sending the short URL link to a restoring server so that the restoring server replaces short character strings contained in the short URL link with long character strings according to the mapping relation; and receiving the replaced URL link returned by the restoring server to serve as a restoring result of the short URL link.
Optionally, the short character strings in the mapping relationship include short character string identifiers; the reduction result of the short URL link is obtained by the following steps:
identifying a short character string in the short URL link according to the short character string identification,
and replacing the identified short character strings with long character strings according to the mapping relation.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
Counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
According to a third aspect of one or more embodiments of the present specification, there is provided a two-dimensional code generating apparatus, including:
the acquisition unit is used for acquiring a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string;
a replacement unit that replaces the long character string contained in the target URL link with the short character string according to a mapping relationship between a pre-configured long character string and the short character string, so as to obtain a short URL link corresponding to the target URL link;
and the generation unit is used for generating a two-dimensional code based on the short URL link.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Optionally, the acquiring unit is specifically configured to:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; or alternatively, the process may be performed,
acquiring the original URL link;
and adopting the URL encoding algorithm to encode each level of sub-links in the original URL link respectively to obtain the target URL link.
Optionally, the URL coding algorithm is adopted to code any one of the separation character strings to obtain a long character string, and the long character string and any one of the separation character strings are in one-to-one correspondence; the mapping relation is one-to-one correspondence relation between the long character strings and the short character strings.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
According to a fourth aspect of one or more embodiments of the present specification, there is provided a two-dimensional code recognition apparatus, including:
the analysis unit analyzes the target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings;
an acquisition unit that acquires a reduction result for the short URL link and takes the reduction result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Alternatively to this, the method may comprise,
the mapping relation is configured locally; the acquisition unit is specifically configured to: replacing short character strings contained in the short URL links with long character strings according to the mapping relation configured locally; or alternatively, the process may be performed,
the acquisition unit is specifically configured to: sending the short URL link to a restoring server so that the restoring server replaces short character strings contained in the short URL link with long character strings according to the mapping relation; and receiving the replaced URL link returned by the restoring server to serve as a restoring result of the short URL link.
Optionally, the short character strings in the mapping relationship include short character string identifiers; the reduction result of the short URL link is obtained by the following steps:
identifying a short character string in the short URL link according to the short character string identification,
and replacing the identified short character strings with long character strings according to the mapping relation.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
And establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
According to a fifth aspect of one or more embodiments of the present specification, there is provided an electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of the first aspect by executing the executable instructions.
According to a sixth aspect of one or more embodiments of the present specification, there is provided an electronic device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of the second aspect by executing the executable instructions.
According to a seventh aspect of one or more embodiments of the present description, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method as described in the first aspect.
According to an eighth aspect of one or more embodiments of the present description, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method as described in the second aspect.
In the embodiment of the present disclosure, the original URL link includes multiple levels of nested sub-links, each level of sub-links is distinguished by a separation string, and when the sub-link content itself includes a separation string (i.e., the separation string belongs to at least a part of the sub-link content), the separation string included in the sub-link content itself has a problem of "confusion", and then each level of sub-links cannot be correctly identified based on the separation string. Therefore, the URL encoding algorithm is adopted to encode the separation character strings corresponding to any level sub-links into corresponding long character strings so as to solve the problem of confusion.
In one aspect, the separate strings included in each level of sub-links in the original URL link are encoded into long strings of relatively longer character lengths, resulting in a longer encoded target URL link. On the other hand, each of the encoded separation strings may be the same separation string, which results in the encoded target URL link containing a large number of repeated encoded content. As the target URL link length obtained by encoding is increased and the repeated content is more, the generated two-dimensional code is more complex.
Therefore, the mapping relation between the long character string and the short character string is pre-configured, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and complexity of the target URL link are effectively reduced, the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. And when the two-dimensional code is identified, the original URL link is restored according to the pre-configured mapping relation.
Drawings
Fig. 1 is a flowchart of a two-dimensional code generating method according to an exemplary embodiment.
Fig. 2 is a flowchart of a two-dimensional code recognition method according to an exemplary embodiment.
Fig. 3A is a flowchart of another two-dimensional code generation method according to an exemplary embodiment.
Fig. 3B is a schematic diagram of a two-dimensional code according to an exemplary embodiment.
Fig. 4 is a flowchart of another two-dimensional code recognition method according to an exemplary embodiment.
Fig. 5 is a schematic structural diagram of an electronic device according to an exemplary embodiment.
Fig. 6 is a block diagram of a two-dimensional code generating apparatus according to an exemplary embodiment.
Fig. 7 is a schematic structural diagram of another electronic device according to an exemplary embodiment.
Fig. 8 is a block diagram of another two-dimensional code generating apparatus provided by an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with aspects of one or more embodiments of the present description as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, individual steps described in this specification, in other embodiments, may be described as being split into multiple steps; while various steps described in this specification may be combined into a single step in other embodiments.
Referring to fig. 1, fig. 1 is a flowchart of a two-dimensional code generating method according to an exemplary embodiment. The method is applied to two-dimensional code generating equipment and can comprise the following steps:
step 102, obtaining a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string.
In this embodiment, the original URL link includes multiple levels of nested sub-links, each level of sub-links is distinguished by a separation string, and when the sub-link content itself includes a separation string (i.e., the separation string belongs to at least a part of the sub-link content), the separation string included in the sub-link content itself has a problem of "confusion", and then each level of sub-links cannot be correctly identified based on the separation string. Therefore, the URL encoding algorithm is adopted to encode the separation character strings corresponding to any level sub-links into corresponding long character strings so as to solve the problem of confusion.
In one aspect, the separate strings included in each level of sub-links in the original URL link are encoded into long strings of relatively longer character lengths, resulting in a longer encoded target URL link. On the other hand, each of the encoded separation strings may be the same separation string, which results in the encoded target URL link containing a large number of repeated encoded content. As the target URL link length obtained by encoding is increased and the repeated content is more, the generated two-dimensional code is more complex. Therefore, the mapping relation between the long character string and the short character string is pre-configured, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and complexity of the target URL link are effectively reduced, the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. And when the two-dimensional code is identified, the original URL link is restored according to the pre-configured mapping relation.
Further, the original URL link includes multiple levels of nested sub-links, and the separation strings in the original URL link are used to mark the contents of each level of sub-links, so that each level of sub-links can be distinguished by the separation strings. For example, a character string indicating the start position and the end position of the sub-link may be used as the separation character string. However, since the uniform separation string is used as the recognition basis, when the sub-link content itself also includes the separation string (i.e., the separation string belongs to at least a part of the sub-link content), the separation string included in the sub-link content itself has a problem of confusion, and then the sub-links of each level cannot be correctly recognized based on the separation string.
In order to solve the problem, a URL coding algorithm is adopted to code the separation character string corresponding to any level sub-link into a corresponding long character string, the coding frequency of the sub-link of any level is equal to the nesting level number of the sub-link of the level, and the long character string obtained by coding is still used as the separation character string corresponding to the sub-link of the level in the next coding process. Based on the URL encoding mode, the number of encoding times of any level of sub-links is more than the number of encoding times of the previous level of sub-links, and then the separation character string contained in the content of any level of sub-links is a long character string obtained by URL encoding the separation character string corresponding to the previous level of sub-links. In other words, each level of sub-links corresponds to different separation strings, and the separation strings between adjacent levels of sub-links are in a "derived" relationship, so that the above-mentioned "confusion" problem does not exist. Thus, the sub-links of each level may still be distinguished from each other by the separation strings corresponding to the nesting level to which they belong.
For example, in the http protocol, the transmission form of the parameter is "key=value", and when a plurality of parameters need to be transmitted, the "&" symbol may be used to divide the key value pair. For example, the URL link is "https:// www.alipay.comname1 =value 1& name 2=value 2", and then the server end analyzing the URL link divides each parameter according to "&" and then divides the parameter value by "=". In other words, "&" = "is uniformly used as the separation strings (of course, the separation strings may be flexibly selected according to the URL link specific content).
However, as network traffic becomes more complex, URL links need to contain multiple levels of nested sub-links. The above-described partitioning approach suffers from "confusion" when the URL links contain multiple levels of nested sub-links. For example, the original URL links are:
https://www.alipay.comthirdParam=https://www.baidu.comparam1=1&param2=https://www.taobao.comsubP1=c&subP2=d。
wherein the parameter "thirdParam" contains two levels of nested sub-links: the level 1 sub-links are "https:// www.baidu.comparam1 =1 & param2="; the value of parameter param2 (same level as parameter param 1) is level 2 sub-link: https:// www.taobao.comsubP1 = c & subp2 = d. In the above-described division method, the "subp1=c & subp2=d" in the level 2 sub-link has a problem of confusion, and cannot be identified as the value of the parameter param2, but may be identified as another parameter at the same level as the parameter param 1=1 and the parameter param 2.
Thus, the original URL links described above may be URL encoded using a URL encoding algorithm to solve the "confusion" problem described above. Specifically, the URL coding algorithm is adopted to code the separation character string corresponding to any level sub-link into a corresponding long character string, the coding frequency of the sub-link of any level is equal to the nesting level number of the sub-link of the level, and the long character string obtained by coding is still used as the separation character string corresponding to the sub-link of the level in the next coding process. In other words, it can be understood what level of sub-links need to be encoded several times. The length of the long string obtained by encoding the separation string is larger than the length of the separation string.
Taking the UrlEncode code as an example, the separation string and the long string corresponding to the original URL link are shown in Table 1:
separation character string Coding 1 time to obtain long character string Encoding 2 times to obtain long character string
:// %3a%2f%2f %253a%252f%252f
%3f %253f
%3d %253d
& %26 %2526
…… …… ……
TABLE 1
According to the coding mode recorded in table 1, URL coding is performed 1 time on the 1 st-level sub-link to obtain: https%3a%2f%2 fww.baidu.com% 3 fparaam 1%3d1%26param2%3d. For the level 2 sub-links, 2 URL encodings are required, where the result of the level 1 URL encoding is: https%3a%2f%2 fww.taobao.com% 3fsubP1%3dc%26 subsubP2% 3dd; and carrying out URL encoding for the 2 nd time on the basis of the encoding result, wherein the obtained encoding result is as follows: https% 255 a%252f%252 fww.taobao.com% 255 fsubP1% 255 dc%2526subP2% 255 dd.
Thus, the target URL link obtained by URL encoding the original URL link is: https:// www.alipay.comthirdParam = https%3a%2f%2fwwww.baidu.com%3fparaam1%3d1%26param2%3dhttps%253a%252 f%252 fwwww.taobao.com%253fsubP1%255 dc%2526subsub2%253dd.
When decoding the destination URL link (urlrecode decoding), the 1 st decoding results in:
https:// www.alipay.comthirdParam = https:// www.baidu.comparam1 = 1& param2 = https%3a%2f%2fww.taobao.com%3fsubP1%3dc%26subP2%3dd. The level 1 sub-link can be found as "https:// www.baidu.comparam1 =1 & param2="; the value of parameter param2 is the level 2 sub-link. Further, the 2 nd decoding is performed, and the obtained result is:
https:// www.alipay.comthirdParam = https:// www.baidu.comparam1 = 1& param2 = https:// www.taobao.comsubP1 = c & subp2 = d. The parameter param2 thus obtained has the value https:// www.taobao.comsubP1 =c & subp2=d.
In this embodiment, in one case, the user may first perform URL encoding on the original URL link by using the URL link encoding apparatus to obtain a corresponding target URL link, and then input the target URL link in the two-dimensional code generating apparatus, so that the two-dimensional code generating apparatus generates the two-dimensional code. Then, the two-dimensional code generating apparatus may detect the content input in the input area of the URL link and take the detected content as the target URL link. In another case, the function of URL encoding may be integrated in the two-dimensional code generating apparatus, that is, the two-dimensional code generating apparatus obtains the original URL link (for example, the original URL link may be input to the two-dimensional code generating apparatus by the user), and then the URL encoding algorithm is used to encode each level of sub-link in the original URL link to obtain the target URL link.
And 104, replacing the long character string contained in the target URL link with the short character string according to the pre-configured mapping relation between the long character string and the short character string, so as to obtain the short URL link corresponding to the target URL link.
In this embodiment, on the one hand, the separation strings included in each level of sub-links in the original URL link are encoded into long strings with relatively longer character lengths, and the more the number of times of encoding, the longer the long strings generated after encoding, resulting in a longer target URL link obtained by encoding. On the other hand, each of the encoded separation strings may be the same separation string, which results in the encoded target URL link containing a large number of repeated encoded content. As the target URL link length obtained by encoding is increased and the repeated content is more, the generated two-dimensional code is more complex.
Aiming at the problem, the mapping relation between the long character string and the short character string can be pre-configured, so that the long character string contained in the target URL link obtained by encoding is replaced by the short character string based on the mapping relation, the length and complexity of the target URL link are effectively reduced, then the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. And when the two-dimensional code is identified, the original URL link is restored according to the pre-configured mapping relation. The long character strings obtained by encoding any separation character string by adopting a URL encoding algorithm are in one-to-one correspondence with any separation character string, and the long character strings and the short character strings in the mapping relation are in one-to-one correspondence.
In the present embodiment, the mapping relationship may be established based on the occurrence frequency of each long character string. In particular, a set of links may be obtained that includes a number of sample URL links that include hierarchically nested sub-links and are encoded using a URL encoding algorithm. For example, several original URL links including sub-links nested in multiple levels may be obtained and URL-encoded, so that the encoding result (the link obtained by URL-encoding the original URL link is the sample URL link) is used as the link set. And then counting the occurrence frequency of each long character string in the link set, and establishing the mapping relation between each long character string and each short character string according to the occurrence frequency. The length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string. Therefore, by establishing the mapping relation based on the occurrence frequency, the longer the occurrence probability of the long character string in the link after the original URL link is encoded, the shorter the length of the short character string corresponding to the long character string, the shortest the length of the finally obtained short URL link, and further the two-dimensional code generated based on the short URL link is correspondingly simplest. For example, huffman coding (Huffman coding, also called Huffman coding) may be employed to construct a codeword with the shortest average length of the heteronym header based on the probability of occurrence of the character.
And step 106, generating a two-dimensional code based on the short URL link.
In this embodiment, any algorithm for generating a two-dimensional code may be used to generate a corresponding two-dimensional code based on a short URL link, which is not limited by one or more embodiments of the present disclosure. For example, the types of the two-dimensional codes may be Data Matrix, maxi Code, aztec, QR Code, vericode, PDF417, ultracode, code, code 16K, etc., and the algorithm for generating the two-dimensional codes is different for different types of two-dimensional codes. For example, a two-dimensional code generator can be used to select the type of the two-dimensional code to be generated and the corresponding algorithm.
Correspondingly, aiming at the two-dimensional code generation method, the specification also provides a two-dimensional code identification method. As shown in fig. 2, the method is applied to two-dimensional code identification equipment, and may include the following steps:
step 202, analyzing a target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings.
In this embodiment, the process of performing URL encoding on the original URL link to obtain the target URL link and the process of establishing the mapping relationship may refer to the corresponding parts of the embodiment shown in fig. 2, which are not described herein again.
Step 204, obtaining a reduction result for the short URL link, and using the reduction result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
In this embodiment, in one case, since the mapping relationship is fixed (is a one-to-one correspondence relationship) and no calculation is required to complete the conversion between the long character string and the short character string, the mapping relationship can be configured locally in the two-dimensional code recognition device, the storage space occupied by the mapping relationship is small, and meanwhile, the mapping relationship is utilized to complete the conversion between the long character string and the short character string, so that the processing resource occupied by the operation is also small. Therefore, the short character strings contained in the short URL link obtained by analyzing the target two-dimensional code can be replaced with long character strings based on the mapping relationship configured locally.
In another case, the mapping relationship may be configured in the restoration server, so that the restoration server uses the mapping relationship to complete the conversion between the long character string and the short character string, thereby further reducing the occupation of the storage space and the processing resource of the two-dimensional code identification device. Based on the above, after the two-dimension code recognition device analyzes the target two-dimension code to obtain the short URL link, the short URL link may be sent to the restore server, so that the restore server replaces the short character string contained in the short URL link with the long character string according to the mapping relationship configured locally, and thus the two-dimension code recognition device may receive the replaced URL link returned by the restore server as a restore result of the short URL link.
In this embodiment, a short string identifier may be added to the short string to indicate the identity of the short string, so as to distinguish the short string from other strings, which is beneficial to improving the recovery efficiency. For example, a character or character string not included in the target URL link may be selected as the short character string identification. Therefore, in the restoration process of replacing the short character string with the long character string by using the mapping relationship, the short character string in the short URL link is identified according to the short character string identification, and then the identified short character string is replaced with the long character string according to the mapping relationship. The specific form of the short string identifier can be flexibly set according to specific situations, and one or more embodiments of the present disclosure are not limited thereto.
As can be seen from the above embodiments, the original URL link includes multiple levels of nested sub-links, each level of sub-links is distinguished by a separation string, and when the sub-link content itself includes a separation string (i.e., the separation string belongs to at least a part of the sub-link content), the separation string included in the sub-link content itself has a problem of "confusion", and then each level of sub-links cannot be correctly identified based on the separation string. Therefore, the URL coding algorithm is adopted to code the separation character string corresponding to any level sub-link into a corresponding long character string, the coding times of the sub-link of any level are equal to the nesting level number of the sub-link of the level, and the long character string obtained by coding is still used as the separation character string corresponding to the sub-link of the level in the next coding process. Based on the URL encoding mode, the number of encoding times of any level of sub-links is more than the number of encoding times of the previous level of sub-links, and then the separation character string contained in the content of any level of sub-links is a long character string obtained by URL encoding the separation character string corresponding to the previous level of sub-links. In other words, each level of sub-links corresponds to different separation strings, and the separation strings between adjacent levels of sub-links are in a "derived" relationship, so that the above-mentioned "confusion" problem does not exist. Thus, the sub-links of each level may still be distinguished from each other by the separation strings corresponding to the nesting level to which they belong.
On the one hand, the separation character strings contained in each level of sub-links in the original URL links are encoded into long character strings with relatively longer character lengths, and the longer the number of times of encoding is, the longer the long character strings generated after encoding are, resulting in longer target URL links obtained by encoding. On the other hand, each of the encoded separation strings may be the same separation string, which results in the encoded target URL link containing a large number of repeated encoded content. As the target URL link length obtained by encoding is increased and the repeated content is more, the generated two-dimensional code is more complex.
Therefore, the mapping relation between the long character string and the short character string is pre-configured, the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, so that the length and complexity of the target URL link are effectively reduced, the two-dimensional code generated based on the short URL link obtained after replacement is relatively simple, and the efficiency of identifying the two-dimensional code is improved. And when the two-dimensional code is identified, the original URL link is restored according to the pre-configured mapping relation.
In order to facilitate understanding, the following describes the two-dimensional code generation and identification scheme in this specification in detail in combination with a scenario and an example.
Referring to fig. 3A, fig. 3A is a flowchart of another two-dimensional code generating method according to an exemplary embodiment. The method is applied to two-dimensional code generating equipment and can comprise the following steps:
step 302, an original URL link is obtained.
In this embodiment, an example will be described in which the function of URL encoding is integrated in a two-dimensional code generation apparatus. The user can input an original URL link to the two-dimensional code generating device and mark the nesting relation among all levels of sub-links, and the two-dimensional code generating device can respectively carry out URL coding on all levels of sub-links in the original URL link by adopting a URL coding algorithm.
Step 304, URL encoding is performed.
For example, the original URL links are:
example,// testapi/openapp = 88888& update = sync & version = 0.1.1111111.11& url =/www/index. Htmlfirst = true & second = {0} & threaded = {1} & for = 1& fifth = true & ex parameters = { "alscItemExt": { "channel key": "{2}," cityId ":" {3}, "stock id": "{4}" source From ":" {5 }. Wherein, the 1 st level sub-link is:
html first=true & second= {0} & threaded= {1} & forth=1 & fifth=true & exP arms=. The level 2 sub-links are:
{"alscItemExt":{"channelKey":"{2}","cityId":"{3}","storeId":"{4}","sourceFro m":"{5}"}}。
taking the UrlEncode code as an example, ": {" is used to indicate the start position of the object to be uploaded, ": }" is used to indicate the end position of the object to be uploaded. Therefore, the above character strings can be selected as the separation character strings, and of course, the above is only an example, and the specific selection mode can be flexibly set according to the content of the original URL. Assume that a separation string selected for an original URL link and a long string (case-less) corresponding thereto are as shown in table 2:
Separation character string Coding 1 time to obtain long character string Encoding 2 times to obtain long character string
={" %3d%7b%22 %3D%257B%2522
":{" %22%3a%7b%22 %2522%253a%257b%2522
"}} %22%7d%7d %2522%257d%257d
":{" %22%3a%7b%22 %2522%253a%257b%2522
":}" %22%3a%7d%22 %2522%253a%257d%2522
{" %7b%22 %257b%2522
":" %22%3a%22 %2522%253a%2522
"" %22%2c%22 %2522%252c%2522
& %26 %2526
%3d %253d
/ %2f %252f
…… …… ……
TABLE 2
Then, 1 URL encoding is performed for the level 1 sub-link to obtain:
%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams%3D。
1 URL encoding is carried out on the level 2 sub-links to obtain:
%7B%22alscItemExt%22%3A%7B%22channelKey%22%3A%22{2}%22%2C%22cityId%22%3A%22{3}%22%2C%22storeId%22%3A%22{4}%22%2C%22sourceFrom%22%3A%22{5}%22%7D%7D。
and carrying out URL encoding for the level 2 sub-link for 2 times to obtain:
%257B%2522alscItemExt%2522%253A%257B%2522channelKey%2522%253A%2522{2}%2522%252C%2522cityId%2522%253A%2522{3}%2522%252C%2522storeId%2522%253A%2522{4}%2522%252C%2522sourceFrom%2522%253A%2522{5}%2522%257D%257D。
in summary, the target URL links obtained after URL encoding is performed on the original URL are:
example://testapi/openappapp=888888&update=sync&version=0.1.1111111.11&url=%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams%3D%257B%2522alscItemExt%2522%253A%257B%2522channelKey%2522%253A%2522{2}%2522%252C%2522cityId%2522%253A%2522{3}%2522%252C%2522storeId%2522%253A%2522{4}%2522%252C%2522sourceFrom%2522%253A%2522{5}%2522%257D%257D。
step 306, replace the long string with a numeric mapping code.
For example, assume that the short string is in the form of n-; wherein, the number n in the middle of the character string is a short character string identifier, and the long character strings are sequentially corresponding to the short character strings. For example, the mapping relationship obtained in the manner of the "frequency of occurrence" described above is shown in table 3:
Figure BDA0002274840380000171
TABLE 3 Table 3
Then, the short URL links obtained after replacing the long character string in the target URL link according to table 3 are:
example://testapi/openappapp=888888&update=sync&version=0.1.1111111.11&url=%2Fwww%2Findex.html%3Ffirst%3Dtrue%26second%3D{0}%26third%3D{1}%26forth%3D1%26fifth%3Dtrue%26exParams~3~alscItemExt~4~channelKey~1~{2}~2~cityId~1~{3}~2~storeId~1~{4}~2~sourceFrom~1~{5}~0~。
step 308, generating a two-dimensional code based on the short URL link.
In this embodiment, any algorithm for generating a two-dimensional code may be used to generate a corresponding two-dimensional code based on a short URL link, which is not limited by one or more embodiments of the present disclosure. For example, the types of the two-dimensional codes may be Data Matrix, maxi Code, aztec, QR Code, vericode, PDF417, ultracode, code, code 16K, etc., and the algorithm for generating the two-dimensional codes is different for different types of two-dimensional codes. For example, a two-dimensional code generator can be used to select the type of the two-dimensional code to be generated and the corresponding algorithm.
As shown in fig. 3B, the two-dimensional code a is a two-dimensional code generated based on an original URL link, and the two-dimensional code B is a two-dimensional code generated based on a short URL link. The mapping relation between the long character string and the short character string is pre-configured, so that the long character string contained in the target URL link obtained by encoding can be replaced by the short character string, the length and complexity of the target URL link are effectively reduced, and then the two-dimensional code B generated based on the short URL link obtained after replacement is relatively simpler than the two-dimensional code A, and the efficiency of identifying the two-dimensional code is improved. And when the two-dimensional code is identified, the original URL link is restored according to the pre-configured mapping relation.
Accordingly, referring to fig. 4, fig. 4 is a flowchart of another two-dimensional code recognition method according to an exemplary embodiment. The method is applied to two-dimensional code identification equipment and can comprise the following steps:
step 402, scan two-dimensional code B.
In this embodiment, the two-dimensional code recognition device may be a mobile phone, a tablet computer, a two-dimensional code scanner, or the like, which is not limited in one or more embodiments of the present disclosure. The following description will take the mobile phone 41 as an example of scanning the two-dimensional code B to access the network resource.
And step 404, analyzing the two-dimensional code B to obtain a short URL link.
And step 406, restoring according to the digital mapping code to obtain the destination URL link.
For example, the mobile phone 41 is locally configured with the digital mapping code shown in table 3, and the mobile phone 41 can replace the short character string contained in the short URL link obtained by analyzing the two-dimensional code B with the long character string according to the locally configured digital mapping code, so as to obtain the destination URL link corresponding to the original URL link in the embodiment shown in fig. 3A, that is, the reverse process of step 306 is not repeated here.
Step 408, accessing the network resource to the server 42 according to the original URL link.
With the above example, the destination URL links available to the mobile phone 41 are:
sample: the// testapi/openapp = 8888888 & update = sync & version = 0.1.1111111.11& url =% 2 fww% 2findex.html%3ffirst%3dtrue%26second%3d {0}%26third%3d {1}%26forth%3d1%26fifth%3dtrue% 26exepart% 3d%257b%2522alsc itemet ext%2522 a%257b%2522channel key%2522 a% 253a%2522{ 2%252c%2522 citid% 2522{ 3a%2522{3}%2522 c%2522 reid% 253a% 2524 }%2522 c% 25c% 25b% 252 b%2522 b% 25225 a% 253 d% 25225 d%2522 b% 25b% 253a%2522{ 253a% 25b% 252 {2 b. Further, the mobile phone 41 performs the UrlDecode decoding on the destination URL to access the corresponding network resource to the server 42 according to the decoded URL link.
Corresponding to the method embodiment, the present specification also provides an embodiment of a two-dimensional code generating device.
The embodiment of the two-dimensional code generating device of the present specification can be applied to an electronic device. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. Taking software implementation as an example, the device in a logic sense is formed by reading corresponding computer program instructions in a nonvolatile memory into a memory by a processor of an electronic device where the device is located for operation.
In terms of hardware, please refer to fig. 5, fig. 5 is a schematic block diagram of an electronic device according to an exemplary embodiment. At the hardware level, as shown in fig. 5, the device includes a processor 502, an internal bus 504, a network interface 506, a memory 508, and a non-volatile storage 510, although other services may be required. The processor 502 reads a corresponding computer program from the nonvolatile memory 510 into the memory 508 and then runs the computer program, and forms a two-dimensional code generating device on a logic level. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Referring to fig. 6, in a software embodiment, the two-dimensional code generating apparatus may include:
an acquisition unit 61 that acquires a target URL link obtained by encoding an original URL link including multi-level nested sub-links with a URL encoding algorithm for encoding a separation string corresponding to any one level sub-link into a corresponding long string;
a replacement unit 62 that replaces the long character string included in the target URL link with the short character string according to a mapping relationship of the pre-configured long character string and the short character string to obtain a short URL link corresponding to the target URL link;
the generating unit 63 generates a two-dimensional code based on the short URL link.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Optionally, the acquiring unit 61 is specifically configured to:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; or alternatively, the process may be performed,
Acquiring the original URL link;
and adopting the URL encoding algorithm to encode each level of sub-links in the original URL link respectively to obtain the target URL link.
Optionally, the URL coding algorithm is adopted to code any one of the separation character strings to obtain a long character string, and the long character string and any one of the separation character strings are in one-to-one correspondence; the mapping relation is one-to-one correspondence relation between the long character strings and the short character strings.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
Corresponding to the method embodiment, the present specification also provides an embodiment of a two-dimensional code recognition device.
The embodiment of the two-dimensional code recognition device can be applied to electronic equipment. The apparatus embodiments may be implemented by software, or may be implemented by hardware or a combination of hardware and software. Taking software implementation as an example, the device in a logic sense is formed by reading corresponding computer program instructions in a nonvolatile memory into a memory by a processor of an electronic device where the device is located for operation.
In terms of hardware, please refer to fig. 7, fig. 7 is a schematic block diagram of an electronic device according to an exemplary embodiment. At the hardware level, as shown in fig. 7, the device includes a processor 702, an internal bus 704, a network interface 706, memory 708, and non-volatile storage 710, although other hardware required by the service is possible. The processor 702 reads the corresponding computer program from the nonvolatile memory 710 into the memory 708 and then runs the computer program to form the two-dimensional code recognition device on a logic level. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Referring to fig. 8, in a software embodiment, the two-dimensional code identification device may include:
the parsing unit 81 parses the target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings;
An acquisition unit 82 that acquires a restoration result for the short URL link and regards the restoration result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
Optionally, a long character string obtained by encoding any level of sub-links by adopting the URL encoding algorithm is used as a separation character string corresponding to the level of sub-links in the next encoding process, and the separation character string is used for marking the content of each level of sub-links, and the encoding times of the sub-links of any level are equal to the number of nesting levels to which the level of sub-links belong.
Alternatively to this, the method may comprise,
the mapping relation is configured locally; the acquiring unit 82 specifically is configured to: replacing short character strings contained in the short URL links with long character strings according to the mapping relation configured locally; or alternatively, the process may be performed,
the acquiring unit 82 specifically is configured to: sending the short URL link to a restoring server so that the restoring server replaces short character strings contained in the short URL link with long character strings according to the mapping relation; and receiving the replaced URL link returned by the restoring server to serve as a restoring result of the short URL link.
Optionally, the short character strings in the mapping relationship include short character string identifiers; the reduction result of the short URL link is obtained by the following steps:
identifying a short character string in the short URL link according to the short character string identification,
and replacing the identified short character strings with long character strings according to the mapping relation.
Optionally, the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by the computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present invention, and it is not intended to limit the embodiment(s) of the present invention to the particular embodiment(s) described.

Claims (24)

1. The two-dimensional code generation method is characterized by comprising the following steps of:
obtaining a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by using a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string;
according to the mapping relation between the pre-configured long character strings and the short character strings, the long character strings contained in the target URL links are replaced by the short character strings, so that the short URL links corresponding to the target URL links are obtained;
and generating a two-dimensional code based on the short URL link.
2. The method according to claim 1, wherein a long string obtained by encoding any level of sub-links by using the URL encoding algorithm is used as a separation string corresponding to the level of sub-links in the next encoding process, where the separation string is used to mark the content of each level of sub-links, and the number of encoding times for any level of sub-links is equal to the number of nesting levels to which the level of sub-links belong.
3. The method of claim 1, wherein the obtaining the target URL link comprises:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; or alternatively, the process may be performed,
acquiring the original URL link;
and adopting the URL encoding algorithm to encode each level of sub-links in the original URL link respectively to obtain the target URL link.
4. The method of claim 1, wherein a long string obtained by encoding any one of the separate strings by using the URL encoding algorithm has a one-to-one correspondence with the any one of the separate strings; the mapping relation is one-to-one correspondence relation between the long character strings and the short character strings.
5. The method according to claim 1, characterized in that the mapping relation is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
6. The two-dimensional code identification method is characterized by comprising the following steps of:
analyzing the target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings;
obtaining a reduction result aiming at the short URL link, and taking the reduction result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
7. The method of claim 6, wherein a long string obtained by encoding any level of sub-links by using the URL encoding algorithm is used as a separation string corresponding to the level of sub-links in the next encoding process, and the separation string is used to mark the content of each level of sub-links, and the number of encoding times for any level of sub-links is equal to the number of nesting levels to which the level of sub-links belong.
8. The method of claim 6, wherein the step of providing the first layer comprises,
the mapping relation is configured locally; the obtaining the reduction result of the short URL link includes: replacing short character strings contained in the short URL links with long character strings according to the mapping relation configured locally; or alternatively, the process may be performed,
the obtaining the reduction result of the short URL link includes: sending the short URL link to a restoring server so that the restoring server replaces short character strings contained in the short URL link with long character strings according to the mapping relation; and receiving the replaced URL link returned by the restoring server to serve as a restoring result of the short URL link.
9. The method of claim 6, wherein the short string in the mapping relationship comprises a short string identifier; the reduction result of the short URL link is obtained by the following steps:
identifying a short character string in the short URL link according to the short character string identification,
and replacing the identified short character strings with long character strings according to the mapping relation.
10. The method of claim 6, wherein the mapping relationship is obtained by:
Acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
11. A two-dimensional code generation apparatus, comprising:
the acquisition unit is used for acquiring a target URL link, wherein the target URL link is obtained by encoding an original URL link comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding a separation character string corresponding to any level sub-link into a corresponding long character string;
a replacement unit that replaces the long character string contained in the target URL link with the short character string according to a mapping relationship between a pre-configured long character string and the short character string, so as to obtain a short URL link corresponding to the target URL link;
and the generation unit is used for generating a two-dimensional code based on the short URL link.
12. The apparatus of claim 11, wherein a long string obtained by encoding any level of sub-links using the URL encoding algorithm is used as a separation string corresponding to the level of sub-links in a next encoding process, where the separation string is used to mark the content of each level of sub-links, and the number of encoding times for any level of sub-links is equal to the number of nesting levels to which the level of sub-links belong.
13. The apparatus according to claim 11, wherein the acquisition unit is specifically configured to:
detecting content input in an input area of a URL link, and taking the detected content as the target URL link; or alternatively, the process may be performed,
acquiring the original URL link;
and adopting the URL encoding algorithm to encode each level of sub-links in the original URL link respectively to obtain the target URL link.
14. The device of claim 11, wherein a long string obtained by encoding any one of the separation strings by using the URL encoding algorithm has a one-to-one correspondence with the any one of the separation strings; the mapping relation is one-to-one correspondence relation between the long character strings and the short character strings.
15. The apparatus of claim 11, wherein the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
16. A two-dimensional code recognition device, characterized by comprising:
the analysis unit analyzes the target two-dimensional code to obtain a short URL link; the short URL links are obtained by replacing long character strings contained in target URL links with short character strings according to the mapping relation between the pre-configured long character strings and the short character strings, the target URL links are obtained by encoding original URL links comprising multi-level nested sub-links by adopting a URL encoding algorithm, and the URL encoding algorithm is used for encoding separation character strings corresponding to any level sub-links into corresponding long character strings;
an acquisition unit that acquires a reduction result for the short URL link and takes the reduction result as a target URL link corresponding to the target two-dimensional code; and the restoration result is obtained by replacing the short character string contained in the short URL link with a long character string according to the mapping relation.
17. The apparatus of claim 16, wherein a long string obtained by encoding any level of sub-links using the URL encoding algorithm is used as a separation string corresponding to the level of sub-links in the next encoding process, where the separation string is used to mark the content of each level of sub-links, and the number of encoding times for any level of sub-links is equal to the number of nesting levels to which the level of sub-links belong.
18. The apparatus of claim 16, wherein the device comprises a plurality of sensors,
the mapping relation is configured locally; the acquisition unit is specifically configured to: replacing short character strings contained in the short URL links with long character strings according to the mapping relation configured locally; or alternatively, the process may be performed,
the acquisition unit is specifically configured to: sending the short URL link to a restoring server so that the restoring server replaces short character strings contained in the short URL link with long character strings according to the mapping relation; and receiving the replaced URL link returned by the restoring server to serve as a restoring result of the short URL link.
19. The apparatus of claim 16, wherein the short string in the mapping relationship comprises a short string identifier; the reduction result of the short URL link is obtained by the following steps:
identifying a short character string in the short URL link according to the short character string identification,
and replacing the identified short character strings with long character strings according to the mapping relation.
20. The apparatus of claim 16, wherein the mapping relationship is obtained by:
acquiring a link set comprising a plurality of sample URL links, wherein the sample URL links comprise multi-level nested sub-links and are encoded by adopting the URL encoding algorithm;
Counting the occurrence frequency of each long character string in the link set;
and establishing a mapping relation between each long character string and each short character string according to the occurrence frequency, wherein the length of the short character string corresponding to any long character string is inversely related to the occurrence frequency of any long character string.
21. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of claims 1-5 by executing the executable instructions.
22. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of claims 6-10 by executing the executable instructions.
23. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method according to any of claims 1-5.
24. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method according to any of claims 6-10.
CN201911118805.5A 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium Active CN111027656B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911118805.5A CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911118805.5A CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111027656A CN111027656A (en) 2020-04-17
CN111027656B true CN111027656B (en) 2023-04-28

Family

ID=70200353

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911118805.5A Active CN111027656B (en) 2019-11-15 2019-11-15 Two-dimensional code generation and identification method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111027656B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111695051B (en) * 2020-05-06 2022-03-25 支付宝(杭州)信息技术有限公司 Page access method and device based on code scanning, electronic equipment and storage medium
CN112149445A (en) * 2020-10-22 2020-12-29 北京京东振世信息技术有限公司 Bar code processing method, device, equipment and storage medium
CN112380464B (en) * 2020-11-10 2023-07-28 中国平安人寿保险股份有限公司 Short link generation method and related equipment
CN113312622A (en) * 2021-06-09 2021-08-27 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Method and device for detecting URL (Uniform resource locator)
CN113468855A (en) * 2021-06-30 2021-10-01 北京达佳互联信息技术有限公司 Data processing method, device, server and storage medium
CN114358230A (en) * 2021-08-17 2022-04-15 深圳市神州路路通网络科技有限公司 Method, system, equipment and storage medium for controlling vehicle to enter and exit parking lot
CN113761406B (en) * 2021-09-03 2024-06-04 丰巢网络技术有限公司 Intelligent cabinet two-dimension code short-chain generation method and device, medium and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1078928A (en) * 1996-07-08 1998-03-24 D & I Syst Kk Internet access method and system and storage medium storing internet access processing
CN102142033A (en) * 2010-05-20 2011-08-03 百度在线网络技术(北京)有限公司 Method and device for providing relative sub-link information in search result
CN103259852A (en) * 2013-04-19 2013-08-21 山东电力集团公司 Distributed type data splicing method based on URI
CN104966218A (en) * 2015-07-09 2015-10-07 浙江工商大学 Two-dimension code advertisement putting and channel evaluating method based on dual URLs (uniform resource locators)
CN106375189A (en) * 2016-08-31 2017-02-01 北京炎黄新星网络科技有限公司 Long and short link switching method and system
CN106933871A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and short linked server
CN108228710A (en) * 2017-11-30 2018-06-29 中国科学院信息工程研究所 A kind of segmenting method and device for URL

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8630200B2 (en) * 2010-06-01 2014-01-14 Meltwater News International Holdings, GmbH Method and apparatus for embedding information in a short URL
JP7073679B2 (en) * 2017-11-02 2022-05-24 ブラザー工業株式会社 2D code generator

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1078928A (en) * 1996-07-08 1998-03-24 D & I Syst Kk Internet access method and system and storage medium storing internet access processing
CN102142033A (en) * 2010-05-20 2011-08-03 百度在线网络技术(北京)有限公司 Method and device for providing relative sub-link information in search result
CN103259852A (en) * 2013-04-19 2013-08-21 山东电力集团公司 Distributed type data splicing method based on URI
CN104966218A (en) * 2015-07-09 2015-10-07 浙江工商大学 Two-dimension code advertisement putting and channel evaluating method based on dual URLs (uniform resource locators)
CN106933871A (en) * 2015-12-30 2017-07-07 阿里巴巴集团控股有限公司 Short linking processing method, device and short linked server
CN106375189A (en) * 2016-08-31 2017-02-01 北京炎黄新星网络科技有限公司 Long and short link switching method and system
CN108228710A (en) * 2017-11-30 2018-06-29 中国科学院信息工程研究所 A kind of segmenting method and device for URL

Also Published As

Publication number Publication date
CN111027656A (en) 2020-04-17

Similar Documents

Publication Publication Date Title
CN111027656B (en) Two-dimensional code generation and identification method and device, electronic equipment and storage medium
CN106649346B (en) Data repeatability checking method and device
CN103400174B (en) The coded method of a kind of Quick Response Code, coding/decoding method and system
TW201710957A (en) Generating and decoding two-dimensional code
US10366315B1 (en) Generating a quick response (QR) grid associated with a digital document
CN111539502B (en) Anti-counterfeiting two-dimensional code generation method and device, server and storage medium
CN112398838B (en) Authentication method, device, equipment and storage medium based on privacy protection
CN114448563B (en) Semantic code transmission method and electronic equipment
CN112381216A (en) Training and predicting method and device for mixed graph neural network model
CN116978011B (en) Image semantic communication method and system for intelligent target recognition
CN114020272A (en) Serialized encoding and decoding methods and devices and electronic equipment
US20170068830A1 (en) Symmetric bit coding for printed memory devices
CN112910890B (en) Anonymous network flow fingerprint identification method and device based on time convolution network
CN113239225A (en) Image retrieval method, device, equipment and storage medium
CN112491816A (en) Service data processing method and device
CN110266834B (en) Area searching method and device based on internet protocol address
CN107645665B (en) WebP entropy coding method and device
CN110138501B (en) Decoding method and device for FM0 codes
JP6984729B2 (en) Semantic estimation system, method and program
CN114500670B (en) Encoding compression method, decoding method and device
CN111723122A (en) Method, device and equipment for determining association rule between data and readable storage medium
CN114092577A (en) Image data processing method, image data processing device, computer equipment and storage medium
US8375066B2 (en) Generating unique identifiers
CN110059563B (en) Text processing method and device
CN110059272B (en) Page feature recognition method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant