Parsing HTTP User-Agent string

2019-01-10 22:12发布

What is the best method to parse a User-Agent string in Python to reliably detect

  1. Browser
  2. Browser version
  3. OS

Or perhaps any helper library that does it

7条回答
你好瞎i
2楼-- · 2019-01-10 22:55

The other responses to this question are rather old now. I believe the new standard in Browser User Agent parsing is Browserscope's user agent parser.

Also conveniently available with the exact same matching patterns in many other languages. Someday you might want to also parse some UA strings in JavaScript and you don't need to worry about inconsistent parsing.

查看更多
登录 后发表回答