Method and System for Providing a User Agent String Database
Method, system, and programs for determining a keyword from user agent strings are disclosed. In one example, a plurality of user agent strings is received. The plurality of user agent strings is grouped into one or more clusters. The one or more clusters comprise a first cluster that includes two or more user agent strings. The two or more user agent strings in the first cluster are compared. Based on the comparing, a keyword is determined from the first cluster. The keyword represents a type of user agent information.
1 . A method for analyzing a user agent string, comprising:
receiving the user agent string;
extracting, based on a list of predefined keywords, candidate keywords from the user agent string;
obtaining a plurality of version extraction patterns for each of the candidate keywords, wherein each of the plurality of version extraction patterns indicates a name, a version pattern, and a corresponding matching condition; and
if the matching condition is met,
determining that the candidate keyword corresponds to the name, and
extracting a version according to the version pattern.
2 . The method of claim 1 , further comprising:
validating each of the candidate keywords based on one or more neighbor charsets of the candidate keyword in the user agent string.
3 . The method of claim 1 , wherein the matching condition comprises whether the user agent string includes a predetermined sub-string.
4 . The method of claim 1 , wherein the version pattern is a pattern of characters, associated with the version, expected in the user agent string.
5 . The method of claim 1 , wherein the name corresponds to a name of an operation system and the version corresponds to a version of the operation system.
6 . The method of claim 1 , wherein each of the plurality of version extraction patterns further indicates a position in the version pattern where the version is located.
7 . The method of claim 1 , wherein each of the plurality of version extraction patterns further indicates a next step if the step of extracting a version fails.
8 . A non-transitory, computer-readable medium having information recorded thereon for analyzing a user agent string, wherein the information, when read by a machine, causes the machine to perform operations comprising:
receiving the user agent string;
extracting, based on a list of predefined keywords, candidate keywords from the user agent string;
obtaining a plurality of version extraction patterns for each of the candidate keywords, wherein each of the plurality of version extraction patterns indicates a name, a version pattern, and a corresponding matching condition; and
if the matching condition is met,
determining that the candidate keyword corresponds to the name, and
extracting a version according to the version pattern.
9 . The medium of claim 8 , wherein the operations further comprise:
validating each of the candidate keywords based on one or more neighbor charsets of the candidate keyword in the user agent string.
10 . The medium of claim 8 , wherein the matching condition comprises whether the user agent string includes a predetermined sub-string.
11 . The medium of claim 8 , wherein the version pattern is a pattern of characters, associated with the version, expected in the user agent string.
12 . The medium of claim 8 , wherein the name corresponds to a name of an operation system and the version corresponds to a version of the operation system.
13 . The medium of claim 8 , wherein each of the plurality of version extraction patterns further indicates a position in the version pattern where the version is located.
14 . The medium of claim 8 , wherein each of the plurality of version extraction patterns further indicates a next step if the step of extracting a version fails.
15 . A system for analyzing a user agent string, the system comprising:
memory storing computer program instructions; and
one or more processors that, in response to executing the computer program instructions, effectuate operations comprising:
receiving the user agent string;
extracting, based on a list of predefined keywords, candidate keywords from the user agent string;
obtaining a plurality of version extraction patterns for each of the candidate keywords, wherein each of the plurality of version extraction patterns indicates a name, a version pattern, and a corresponding matching condition; and
if the matching condition is met,
determining that the candidate keyword corresponds to the name, and
extracting a version according to the version pattern.
16 . The system of claim 15 , wherein the operations further comprise:
validating each of the candidate keywords based on one or more neighbor charsets of the candidate keyword in the user agent string.
17 . The system of claim 15 , wherein the matching condition comprises whether the user agent string includes a predetermined sub-string.
18 . The system of claim 15 , wherein the version pattern is a pattern of characters, associated with the version, expected in the user agent string.
19 . The system of claim 15 , wherein the name corresponds to a name of an operation system and the version corresponds to a version of the operation system.
20 . The system of claim 15 , wherein each of the plurality of version extraction patterns further indicates a position in the version pattern where the version is located.