The Python module kpy, which extracts the mobile model name (model name) from the UserAgent, is now compatible with the 2014 winter-2015 winter model mobile.
This module was released without any promotion, so I think there are only people who don't know it, so I'll take this opportunity to introduce it.
--When you want to collect statistics from the access log --Purchasing a terminal with a lot of access as a verification machine --When you want to identify / reproduce the environment where bugs occur on the web or apps --Use as one of browser fingerprint information
etc...
Install
$ pip install kpy
You can put it in.
>>> import kpy
>>> ua = 'Mozilla/5.0 (Linux; U; Android 4.1.1; ja-jp; HTL21 Build/JRO03C AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
>>> kpy.extract(ua)
'HTL21'
Just do ʻimport kpy and let
kpy.extract () `eat the UA!
It is compatible with feature phones, smartphones, tablets, and PHS. I am particularly confident in docomo, and I cover everything from the F501i released in 1999 to the Xperia Z5 Premium SO-03H released on November 20, 2015.
Apple products are not planned to be supported, so if you are interested, please use it in combination with woothee-python.
Because the model name and the notation in UA do not match, it is necessary to create a conversion table.
For example, the UA of the model A5404S is KDDI-SN25 UP.Browser / 6.2.0.5 (GUI) MMP / 2.0
, and the characters A5404S do not appear anywhere.
(Maybe I can't handle it if I'm not very well ...)
Easy specification that just repeats the regular expression multiple times to match the part like the model name.
You can see the source at ↓. https://github.com/ikegami-yukino/kpy
The test UA data is obtained from the following.