UserAgent parsing

During the software development process, we need to analyze some  UserAgent  information, and do corresponding processing according to different UserAgents.

Common UserAgent resolution methods are as follows:

Library parsing UserAgent

Different languages ​​have different parsing UserAgent libraries, for example, in Python, there are  user-agents , ua-parse , Python User Agent Parser , Python User Agents ...

The above libraries have been tested, and their functions are similar and can meet the basic requirements. However, there are still some problems in the analysis results. Sometimes there is a problem with the device version identification, and sometimes there is a problem with the browser identification.

Online UserAgent analysis

We can also analyze UserAgent through online UserAgent analysis , which can easily help us analyze UserAgent. For the usage of online UserAgent analysis, please refer to this article: UserAgent online search . This article is written in detail, so I won’t go into details here.

Advantages and disadvantages comparison

Although there are some problems with the library parsing UserAgent, it is still a very good choice if a large number of parsing is required, or if it is integrated into the publishing software.

The online UsreAgent analysis tool, although the analysis information is relatively complete: it can analyze browser name, browser version, operating system name, operating system version, whether it is a crawler, crawler name, crawler classification, etc., so far no API has been provided, so There may be problems with large batch parsing, but if there is not much information about the query UserAgent, it is still a good choice.

Summarize

Introduced two ways to analyze UserAgent: library analysis UserAgent and online UserAgent analysis, and compared the advantages and disadvantages of these two methods. In specific situations, we can use different methods to analyze UserAgent.

Through the above introduction, do you think UserAgent analysis is very simple?

Guess you like

Origin blog.csdn.net/oHuangBing/article/details/126074408