CN112241621A - Method and device for identifying client environment through user agent - Google Patents

Method and device for identifying client environment through user agent Download PDF

Info

Publication number
CN112241621A
CN112241621A CN201910650150.XA CN201910650150A CN112241621A CN 112241621 A CN112241621 A CN 112241621A CN 201910650150 A CN201910650150 A CN 201910650150A CN 112241621 A CN112241621 A CN 112241621A
Authority
CN
China
Prior art keywords
keyword
processing
processing rule
character
user agent
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.)
Pending
Application number
CN201910650150.XA
Other languages
Chinese (zh)
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910650150.XA priority Critical patent/CN112241621A/en
Publication of CN112241621A publication Critical patent/CN112241621A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • 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/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Machine Translation (AREA)

Abstract

The invention discloses a method and a device for identifying a client environment through a user agent, and relates to the technical field of computers. One embodiment of the method comprises: analyzing the user agent, and determining at least one keyword from the product information obtained by analysis; searching a processing rule corresponding to the keyword from the processing rule set according to a pre-constructed dictionary tree comprising the keyword; the processing rule set comprises keywords and at least one corresponding processing rule; and if the processing rule set has a processing rule corresponding to the keyword, processing the keyword according to the processing rule to obtain the client environment information. According to the method, the keywords are determined from the analyzed product information, the processing rules corresponding to the keywords are searched according to the dictionary tree, the keywords are processed according to the processing rules, the client side environment information is obtained, the processing rules are searched based on the dictionary tree, the identification efficiency is improved, and meanwhile a user can obtain the concerned client side environment information according to the self requirement.

Description

Method and device for identifying client environment through user agent
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for identifying a client environment by a user agent.
Background
A User Agent (User Agent) is a part of a hypertext Transfer Protocol (HTTP) and belongs to a component of a header field. It is a special string header that enables the server to identify the type and version of the browser, operating system and version, browser language, browser plug-in, etc. information used by the client. Although the proposed format of the user agent is defined in RFC1945, the user agent format of each application in actual engineering applications is not uniform. To identify the client environment, engineers may develop thousands of processing rules for different user agent formats. Among them, the RFC in RFC1945, Request For Comments, is a series of files scheduled by numbers, the files collect relevant information about the internet, and 1945 is a description of the HTTP protocol version 1.0.
In the prior art, a user agent is generally identified by means of character string containing judgment and regular expression matching, dozens of types of browsers on the market can be identified by dozens of judgments, and the model and version of equipment can be determined by thousands of judgments.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
(1) as the processing rule increases, the recognition efficiency drops sharply, especially when using regular expression recognition. As processing rules increase, processing time also increases nonlinearly, and part of the information in identifying the user agent is usually discarded to achieve the desired efficiency.
(2) In the user agent identification in the prior art, only a successfully matched user agent part can be processed, which part is not processed cannot be determined, and generally, only a browser, an operating system and a few mainstream mobile devices can be identified, so that the expandability is poor.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for identifying a client environment through a user agent, in which a keyword is determined from parsed product information, and a processing rule corresponding to the keyword is further searched according to a dictionary tree, so as to process the keyword according to the processing rule, thereby obtaining client environment information. The method is based on the dictionary tree lookup processing rule, improves the recognition efficiency, enables the user to acquire the concerned client environment information according to the self requirement, and improves the user experience.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of identifying a client environment through a user agent.
The method for identifying the client environment through the user agent comprises the following steps: analyzing the user agent, and determining at least one keyword from the product information obtained by analysis; searching a processing rule corresponding to the keyword from a processing rule set according to a pre-constructed dictionary tree comprising the keyword; wherein the processing rule set comprises the keyword and at least one corresponding processing rule; and if the processing rule set has the processing rule corresponding to the keyword, processing the keyword according to the processing rule to obtain the client environment information.
Optionally, the parsing user agent includes: converting the character string of the user agent into a character stream; wherein the character stream comprises at least one character; judging whether the character is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result; and summarizing characters contained in the environment field of the product to obtain the product information.
Optionally, when the keyword corresponds to a plurality of processing rules, the processing the keyword according to the processing rules includes: processing the keywords by using the processing rule with the highest priority according to the set priority of the processing rule; if the processing result of the keyword does not meet the exit condition of the processing rule, processing the keyword by using the processing rule with the next high priority; and if the processing result of the keyword meets the exit condition of the processing rule, ending the processing of the keyword.
Optionally, the method further comprises: and inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment fields to construct the dictionary tree.
Optionally, the method further comprises: and if the processing rule set does not have the processing rule corresponding to the keyword, storing the keyword.
Optionally, the product information comprises at least one or more of: the system comprises a product name, a product version, a product label, a browser name, a rendering engine name, an operating system name and a client device model; the keyword is one or more items of the product information.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for identifying a client environment through a user agent.
The embodiment of the invention provides a device for identifying client environment through a user agent, which comprises: the analysis module is used for analyzing the user agent and determining at least one keyword from the product information obtained by analysis; the searching module is used for searching the processing rule corresponding to the keyword from the processing rule set according to a pre-constructed dictionary tree; wherein the processing rule set comprises the keyword and at least one corresponding processing rule; and the processing module is used for processing the keywords according to the processing rules to obtain the client environment information if the processing rules corresponding to the keywords exist in the processing rule set.
Optionally, the parsing module is further configured to: converting the character string of the user agent into a character stream; wherein the character stream comprises at least one character; judging whether the character is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result; and summarizing characters contained in the environment field of the product to obtain the product information.
Optionally, the processing module is further configured to: when the keywords correspond to a plurality of processing rules, processing the keywords by using the processing rule with the highest priority according to the set priority of the processing rules; if the processing result of the keyword does not meet the exit condition of the processing rule, processing the keyword by using the processing rule with the next high priority; and if the processing result of the keyword meets the exit condition of the processing rule, ending the processing of the keyword.
Optionally, the apparatus further comprises: and the construction module is used for inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment fields so as to construct the dictionary tree.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of identifying a client environment by a user agent of an embodiment of the present invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention has stored thereon a computer program that, when executed by a processor, implements a method of identifying a client environment by a user agent of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the method is based on the dictionary tree search processing rule, so that the recognition efficiency is improved, meanwhile, a user can obtain the concerned client environment information according to the self requirement, and the user experience is improved; the keywords can be determined according to the self requirements, so that the corresponding client environment information can be obtained, and the expandability is improved; the dictionary tree stores keywords concerned by the user, the processing rules are searched based on the dictionary tree, the performance cannot be influenced along with the increase of the processing rule set, and the processing rules in the processing rule set can be dynamically expanded.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of identifying a client environment by a user agent according to an embodiment of the invention;
FIG. 2 is a schematic flow chart illustrating a method for identifying a client environment by a user agent according to an embodiment of the present invention;
FIG. 3 is a flow chart illustrating an implementation of parsing a user agent in an embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating a principle of searching a processing rule corresponding to a current keyword according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the major modules of an apparatus for identifying a client environment by a user agent, according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 7 is a schematic diagram of a computer apparatus suitable for use in an electronic device to implement an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main steps of a method of identifying a client environment by a user agent according to an embodiment of the present invention. As shown in fig. 1, the method for identifying a client environment by a user agent according to the embodiment of the present invention mainly includes the following steps:
step S101: and analyzing the user agent, and determining at least one keyword from the analyzed product information. Product information for a plurality of products may be contained in one user agent. In an embodiment, a character string of a user agent is first converted into a character stream comprising at least one character; then, sequentially judging whether each character of the character stream is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result; and finally summarizing characters contained in the environment field of the product to obtain product information. Wherein, the identifier is some special symbols of non-English letters in the user agent, such as backslash, blank space, brackets and the like; context fields such as product name, product version, product label, etc. After the product information is analyzed, keywords can be selected from the environment field of the product information in a user-defined mode.
Step S102: searching a processing rule corresponding to the keyword from a processing rule set according to a pre-constructed dictionary tree comprising the keyword; wherein the processing rule set includes the keyword and a corresponding at least one processing rule. Processing rule sets are initialized in advance, and in order to improve the efficiency of searching the processing rules corresponding to the keywords from the processing rule sets, a data structure of a dictionary tree is introduced. The construction process of the dictionary tree specifically comprises the following steps: and inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment fields to construct the dictionary tree. The context field herein may be a part or all of the context field of the product information that the user is interested in. In an embodiment, the parsed product information may include a plurality of products, and for each product, a processing rule corresponding to the keyword is searched for.
Step S103: and if the processing rule set has the processing rule corresponding to the keyword, processing the keyword according to the processing rule to obtain the client environment information. One keyword may correspond to one or more processing rules, and if a certain keyword corresponds to a plurality of processing rules, the keyword needs to be processed by using the processing rule with a high priority according to the priority level of each processing rule, and the processing on the keyword is ended when the processing result meets the exit condition set by the processing rule.
Fig. 2 is a main flowchart illustrating a method for identifying a client environment by a user agent according to an embodiment of the present invention. As shown in fig. 2, the method for identifying a client environment by a user agent according to the embodiment of the present invention mainly includes the following steps:
step S201: and analyzing the user agent to obtain the product information, and determining the keywords from the product information. The product information may include, but is not limited to, a product name, a product version, and a product label, and the keyword is, for example, a product name. Firstly, converting a user agent into a character stream, sequentially processing each character of the character stream, and converting the character stream into information such as a product name, a product version, a product label and the like.
Assume that the user agent is: mozilla/5.0 (Macintosh; Intel Mac OS X10 _13_3), the result of converting the string into a character stream is: ' M ' O ' z ' I ' l ' a '/' 5 ' ' 0 ' (' M ' a ' c ' I ' n't ' O ' S ' h '; ' I ' n't ' e ' l ', ' M ' a ' c ' O ' S ' "' X" "1 ' 0 ' _ '1 ' 3 ' _3 ') '. Each character of the character stream is processed in turn in the manner shown in fig. 3, and product information can be obtained. In this embodiment, the obtained product information is: the product name is as follows: mozilla, product version: 5.0, product labeling: macintosh; intel Mac OS X10 _13_ 3.
The following illustrates the user agent and the product information obtained by parsing.
The user agent: mozilla/5.0 (Macintosh; Intel Mac OS X10 _13_3) AppleWebKit/537.36(KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.
The product information obtained by analysis includes 4 products, specifically:
1) the product name is as follows: mozilla, product version: 5.0, product labeling: macintosh; intel Mac OS X10 _13_3
2) The product name is as follows: appleWebKit, product version: 537.36, product labeling: KHTML, like Gecko
3) The product name is as follows: chrome, product version: 70.0.3538.77, product labeling: is free of
4) The product name is as follows: safari, product version: 537.36, product labeling: is free of
Step S202: initializing a processing rule set and establishing a dictionary tree. The processing rule set comprises keywords which are concerned by the client environment and belong to the product information, and at least one processing rule corresponding to the keywords. In an embodiment, the keyword may be set in a self-defined manner, for example, a browser name, a rendering engine name, an operating system name, a mobile phone model, and the like, so that client environment information such as the browser, the operating system, the mobile phone model, a mobile phone manufacturer, and the like may be identified. In the embodiment, the execution order of the step is not limited, and it may be executed before step S203.
With a user agent: the micro messenger/6.7.3, the keyword is the product name micro messenger for example, the micro messenger can be analyzed as a micro message APP, and can also be analyzed as a micro message built-in browser. The processing rule set of MicroMessenger may be set to: processing rule 1: processing MicroMessenger into WeChat APP; processing rule 2: the MicroMessenger process is a WeChat built-in browser. Through the processing rules, data of various dimensions can be analyzed from the user agent.
The dictionary tree stores keywords that are of interest to the customer. With a user agent: mozilla/5.0 (Macintosh; Intel Mac OS X10 _13_3) AppleWebKit/537.36(KHTML, like Gecko) Chrome/70.0.3538.77Safari/537.36 for example, if the keywords of interest are two product names of Mozilla and Chrome, then the two keywords of Mozilla and Chrome may be registered in the dictionary tree. In this example, AppleWebKit and Safari were not treated at all.
Step S203: and searching the processing rule corresponding to the current keyword from the processing rule set according to the constructed dictionary tree. Processing rules corresponding to keywords such as product names, product versions, product labels, etc. are searched from the processing rule set through the dictionary tree, which is specifically referred to the description of fig. 4.
Step S204: judging whether a processing rule corresponding to the current keyword exists in the processing rule set, and if so, executing step S205; otherwise, step S206 is executed.
Step S205: the current keyword is processed according to the processing rule, the processing result is stored in the recognized list, and step S207 is executed. It should be noted that if a keyword has a plurality of processing rules, each processing rule is provided with a priority, the keyword can be identified according to a chain processing mode with a low priority, and if a certain processing rule with a high priority can be correctly processed and does not need to be processed by other processing rules, the chain processing is finished. In an embodiment, an exit condition may be set in each processing rule, and if the exit condition is satisfied, the chained processing is exited.
With a user agent: chrome/57.0.2987.132MicroMessenger/6.7.3, the keyword is the product name example, and assuming that the processing rule set of MicroMessenger, the processing rule 1 of priority 1: the product name is processed as WeChat APP, and the quitting condition is as follows: no browser is currently resolved; processing rule 2 of priority 2: the product name is processed as a WeChat built-in browser. Because the processing is performed according to the priority order, it is assumed that before the product name MicroMessenger is processed, the product name Chrome is already processed as the Chrome browser, and then when the product name MicroMessenger is processed, since the exit condition set in the processing rule 1 is already satisfied at this time, the product name MicroMessenger is processed as the WeChat APP, and the processing rule 2 of the priority 2 is not executed.
Step S206: the current keyword is stored in the unrecognized list, and step S207 is performed. If the processing rule corresponding to the current keyword is not found, the keyword is put into the unidentified list so as to ensure that the information is not lost. And subsequently, secondary processing can be carried out on the information corresponding to the keywords in the unidentified list.
Step S207: step S203 is executed with the next keyword as the current keyword until the full partial keyword is recognized.
Fig. 3 is a flowchart illustrating an implementation of parsing a user agent according to an embodiment of the present invention. As shown in fig. 3, an implementation process (i.e., step S201) of parsing a user agent according to the embodiment of the present invention specifically includes:
step S301: the user agent is converted to a character stream. The specific conversion method is described in step S201. The user agent is a character string, and the user agent starts to acquire product information after converting the character string into a byte stream.
Step S302: judging whether the current character of the character stream is not a backslash and is not a separator, if so, executing the step S303; otherwise, step S304 is performed. Wherein the initial value of the current character is the first character of the character stream. If the current character is neither backslash nor separator, then the current character is attributed to the product name.
Step S303: the current character is added to the product name, the next character of the character stream is taken as the current character, and step S302 is performed.
Step S304: judging whether the current character is not a backslash, if so, executing a step S306; otherwise, step S305 is executed. If the current character is not a backslash, it is a separator character. If the current character is a backslash, it can be determined whether the next character is a separator, and if not, it can be determined that the next character belongs to the product version.
Step S305: judging whether the next character is a non-separator, if so, adding the next character as the current character into the product version, and executing the step S306; otherwise, the next character is taken as the current character, and step S306 is executed.
Step S306: judging whether the next character is not a left bracket, if so, executing the step S307; otherwise, step S308 is executed. If the next character is not left bracket, it indicates that the current product analysis is completed, step S307 is executed to take the next character as the current character, step S302 is repeatedly executed, and the next product analysis is started.
Step S307: step S302 is performed with the next character as the current character until the last character of the character stream.
Step S308: judging whether the next character is a right bracket or not, if so, executing the step S307; otherwise, step S309 is performed. If the next character is a right bracket, it indicates that the current product analysis is completed, step S307 is executed, the first character after the right bracket is used as the current character, step S302 is repeatedly executed, and the next product analysis is started. If the next character is not right parenthesis, it may be determined that the next character belongs to the product label.
Step S309: the next character is added as the current character to the product label, and step S308 is executed.
Fig. 4 is a schematic diagram illustrating a principle of searching a processing rule corresponding to a current keyword according to an embodiment of the present invention. The principle of searching the processing rule corresponding to the current keyword based on the dictionary tree is as follows: starting from a root node (root), searching a first character of a current keyword, and if the search is successful, searching a next character of the current keyword based on the current node; if the search fails, the current node is proved to have no child node corresponding to the character.
As shown in fig. 4, taking the example of inserting four words of he, she, his, and hes into the dictionary tree, assuming that the searched character string is his, in the first step, the current node: root; step two, searching h, wherein the searching is successful, and the current node: h; step three, searching i, wherein the searching is successful, and the current node: i; step four, searching for s, wherein the searching is successful, and the current node: s, the number of times of matching is 3 when the search is finished, namely the length of the character string.
For another example, if the searched character string is him, in the first step, the current node: root; step two, searching h, wherein the searching is successful, and the current node: h; step three, searching i, wherein the searching is successful, and the current node: i; and fourthly, searching for m, wherein the searching fails, the node i does not have m child nodes, and the searching is finished at the moment, and the number of times of matching is 2. Therefore, based on the dictionary tree search, in the worst case, the whole character string is required to be traversed to determine whether a certain character exists in the dictionary tree, and the search efficiency is high.
The processing rule corresponding to the current keyword is searched based on the dictionary tree, the searching efficiency is only related to the length of the character string of the current keyword, and the searching efficiency is not reduced due to the increase of the number of the processing rules in the processing rule set. In the worst case, the length of the character string corresponding to the current keyword is matched for several times, so that whether the processing rule set has the processing rule related to the current keyword can be determined.
According to the method for identifying the client environment through the user agent, disclosed by the embodiment of the invention, the keywords are determined from the analyzed product information, and then the processing rules corresponding to the keywords are searched according to the dictionary tree, so that the keywords are processed according to the processing rules to obtain the client environment information; the keywords can be determined according to the self requirements, so that the corresponding client environment information can be obtained, and the expandability is improved; the dictionary tree stores keywords concerned by the user, the processing rules are searched based on the dictionary tree, the performance cannot be influenced along with the increase of the processing rule set, and the processing rules in the processing rule set can be dynamically expanded.
Fig. 5 is a schematic diagram of main modules of an apparatus for recognizing a client environment through a user agent according to an embodiment of the present invention. As shown in fig. 5, an apparatus 500 for identifying a client environment by a user agent according to an embodiment of the present invention mainly includes:
the parsing module 501 is configured to parse the user agent, and determine at least one keyword from the parsed product information. Product information for a plurality of products may be contained in one user agent. In an embodiment, a character string of a user agent is first converted into a character stream comprising at least one character; then, sequentially judging whether each character of the character stream is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result; and finally summarizing characters contained in the environment field of the product to obtain product information. Wherein, the identifier is some special symbols of non-English letters in the user agent, such as backslash, blank space, brackets and the like; context fields such as product name, product version, product label, etc. After the product information is analyzed, keywords can be selected from the environment field of the product information in a user-defined mode.
A searching module 502, configured to search, according to a pre-constructed dictionary tree, a processing rule corresponding to the keyword from a processing rule set; wherein the processing rule set includes the keyword and a corresponding at least one processing rule. Processing rule sets are initialized in advance, and in order to improve the efficiency of searching the processing rules corresponding to the keywords from the processing rule sets, a data structure of a dictionary tree is introduced. The construction process of the dictionary tree specifically comprises the following steps: and inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment fields to construct the dictionary tree. The context field herein may be a part or all of the context field of the product information that the user is interested in. In an embodiment, the parsed product information may include a plurality of products, and for each product, a processing rule corresponding to the keyword is searched for.
The processing module 503 is configured to, if a processing rule corresponding to the keyword exists in the processing rule set, process the keyword according to the processing rule to obtain client environment information. One keyword may correspond to one or more processing rules, and if a certain keyword corresponds to a plurality of processing rules, the keyword needs to be processed by using the processing rule with a high priority according to the priority level of each processing rule, and the processing on the keyword is ended when the processing result meets the exit condition set by the processing rule.
In addition, the apparatus 500 for identifying a client environment by a user agent according to an embodiment of the present invention may further include: a building module (not shown in fig. 5) for inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment field to build the dictionary tree.
From the above description, it can be seen that the processing rules corresponding to the keywords are searched for according to the dictionary tree by determining the keywords from the parsed product information, so as to process the keywords according to the processing rules, and obtain the client environment information; the keywords can be determined according to the self requirements, so that the corresponding client environment information can be obtained, and the expandability is improved; the dictionary tree stores keywords concerned by the user, the processing rules are searched based on the dictionary tree, the performance cannot be influenced along with the increase of the processing rule set, and the processing rules in the processing rule set can be dynamically expanded.
Fig. 6 illustrates an exemplary system architecture 600 of a method of identifying a client environment by a user agent or an apparatus for identifying a client environment by a user agent to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server that provides various services, such as a background management server that provides support for user agents sent by administrators using the terminal devices 601, 602, 603. The background management server may perform processing such as parsing, determining keywords, finding processing rules, processing keywords, and the like on the received user agent, and feed back a processing result (e.g., client environment information) to the terminal device.
It should be noted that the method for identifying the client environment by the user agent provided in the embodiment of the present application is generally executed by the server 605, and accordingly, the apparatus for identifying the client environment by the user agent is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The invention also provides an electronic device and a computer readable medium according to the embodiment of the invention.
The electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of identifying a client environment by a user agent of an embodiment of the present invention.
The computer readable medium of the present invention has stored thereon a computer program which, when executed by a processor, implements a method of identifying a client environment by a user agent of an embodiment of the present invention.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use with an electronic device implementing an embodiment of the present invention. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the computer system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, the processes described above with respect to the main step diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. For example, the disclosed embodiments of the invention include a computer program product comprising a computer program embodied on a computer readable medium, the computer program containing program code for performing the method illustrated in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a parsing module, a lookup module, and a processing module. The names of these modules do not in some cases form a limitation on the module itself, for example, the parsing module may also be described as a "module that parses the user agent to determine at least one keyword from the parsed product information".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: analyzing the user agent, and determining at least one keyword from the product information obtained by analysis; searching a processing rule corresponding to the keyword from a processing rule set according to a pre-constructed dictionary tree comprising the keyword; wherein the processing rule set comprises the keyword and at least one corresponding processing rule; and if the processing rule set has the processing rule corresponding to the keyword, processing the keyword according to the processing rule to obtain the client environment information.
From the above description, it can be seen that the processing rules corresponding to the keywords are searched for according to the dictionary tree by determining the keywords from the parsed product information, so as to process the keywords according to the processing rules, and obtain the client environment information; the keywords can be determined according to the self requirements, so that the corresponding client environment information can be obtained, and the expandability is improved; the dictionary tree stores keywords concerned by the user, the processing rules are searched based on the dictionary tree, the performance cannot be influenced along with the increase of the processing rule set, and the processing rules in the processing rule set can be dynamically expanded.
The product can execute the method provided by the embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiment of the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for identifying a client environment via a user agent, comprising:
analyzing the user agent, and determining at least one keyword from the product information obtained by analysis;
searching a processing rule corresponding to the keyword from a processing rule set according to a pre-constructed dictionary tree comprising the keyword; wherein the processing rule set comprises the keyword and at least one corresponding processing rule;
and if the processing rule set has the processing rule corresponding to the keyword, processing the keyword according to the processing rule to obtain the client environment information.
2. The method of claim 1, wherein parsing the user agent comprises:
converting the character string of the user agent into a character stream; wherein the character stream comprises at least one character;
judging whether the character is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result;
and summarizing characters contained in the environment field of the product to obtain the product information.
3. The method of claim 1, wherein when the keyword corresponds to a plurality of processing rules, the processing the keyword according to the processing rules comprises:
processing the keywords by using the processing rule with the highest priority according to the set priority of the processing rule;
if the processing result of the keyword does not meet the exit condition of the processing rule, processing the keyword by using the processing rule with the next high priority;
and if the processing result of the keyword meets the exit condition of the processing rule, ending the processing of the keyword.
4. The method of claim 2, further comprising:
and inserting the words into the nodes of the dictionary tree according to the character sequence of the words corresponding to the environment fields to construct the dictionary tree.
5. The method of claim 1, further comprising:
and if the processing rule set does not have the processing rule corresponding to the keyword, storing the keyword.
6. The method according to any one of claims 1 to 5, wherein the product information comprises at least one or more of: the system comprises a product name, a product version, a product label, a browser name, a rendering engine name, an operating system name and a client device model; the keyword is one or more items of the product information.
7. An apparatus for identifying a client environment via a user agent, comprising:
the analysis module is used for analyzing the user agent and determining at least one keyword from the product information obtained by analysis;
the searching module is used for searching the processing rule corresponding to the keyword from the processing rule set according to a pre-constructed dictionary tree; wherein the processing rule set comprises the keyword and at least one corresponding processing rule;
and the processing module is used for processing the keywords according to the processing rules to obtain the client environment information if the processing rules corresponding to the keywords exist in the processing rule set.
8. The apparatus of claim 7, wherein the parsing module is further configured to:
converting the character string of the user agent into a character stream; wherein the character stream comprises at least one character;
judging whether the character is a set identifier according to the format of the user agent so as to determine a product to which the character belongs and an environment field according to a judgment result; and
and summarizing characters contained in the environment field of the product to obtain the product information.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201910650150.XA 2019-07-18 2019-07-18 Method and device for identifying client environment through user agent Pending CN112241621A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910650150.XA CN112241621A (en) 2019-07-18 2019-07-18 Method and device for identifying client environment through user agent

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910650150.XA CN112241621A (en) 2019-07-18 2019-07-18 Method and device for identifying client environment through user agent

Publications (1)

Publication Number Publication Date
CN112241621A true CN112241621A (en) 2021-01-19

Family

ID=74168127

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910650150.XA Pending CN112241621A (en) 2019-07-18 2019-07-18 Method and device for identifying client environment through user agent

Country Status (1)

Country Link
CN (1) CN112241621A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115665257A (en) * 2022-12-27 2023-01-31 成都同步新创科技股份有限公司 Request processing method and device based on reverse proxy and dynamic script

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115665257A (en) * 2022-12-27 2023-01-31 成都同步新创科技股份有限公司 Request processing method and device based on reverse proxy and dynamic script

Similar Documents

Publication Publication Date Title
CN107506256B (en) Method and device for monitoring crash data
CN110471848B (en) Method and device for dynamically returning message
CN109933217B (en) Method and device for pushing sentences
US20210042470A1 (en) Method and device for separating words
CN112184367A (en) Order processing method and device
CN111447257A (en) Message conversion method and device
CN114760369B (en) Protocol metadata extraction method, device, equipment and storage medium
CN109753424B (en) AB test method and device
CN113139660A (en) Model reasoning method and device, electronic equipment and storage medium
CN113268955A (en) Message conversion method and device
CN110321252B (en) Skill service resource scheduling method and device
CN111597107A (en) Information output method and device and electronic equipment
CN114461247A (en) Hot update method, device, electronic equipment and computer readable medium
CN114356335A (en) Data processing method, device, equipment and medium
CN112241621A (en) Method and device for identifying client environment through user agent
RU2731122C1 (en) Method, system and device for displaying text
CN112487765B (en) Method and device for generating notification text
CN114819679A (en) Customer service session quality inspection method and device
CN110896391B (en) Message processing method and device
CN109426358B (en) Information input method and device
CN112784596A (en) Method and device for identifying sensitive words
CN113779018A (en) Data processing method and device
CN109308299B (en) Method and apparatus for searching information
CN109426357B (en) Information input method and device
CN112988778A (en) Method and device for processing database query script

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