Grabbing user's agent and OS type
Νικόλαος Κούρας
nikos.kouras at gmail.com
Fri Mar 11 09:37:42 EST 2011
Hello,
I use
os.environ["HTTP_USER_AGENT"] and is very convenient to retrieve the
user's agent type
but how could we also retrieve the user's OS type?
OS type and agent type and version do appear in the same string.
I somehow have to grab the 'OS' type(Windows) and the user's agent/
version(Chrome 11)
The string is:
[code]
Mozilla/5.0 (Windows; Windows NT 6.1) AppleWebKit/534.23 (KHTML, like
Gecko) Chrome/11.0.686.0 Safari/534.23
[/code]
How am i supposed to filter the string since the subsparts of the
string isn't always the same and maybe also in different positions
within the each time different returned string?
For example from he above string i only need to know that the OS type
is 'Windows' and that the agent type is 'Chrome 11'
But those strings vary in each case.
If it cant be done by filtering the value of
os.environ["HTTP_USER_AGENT"] is there any other easier way that i can
retrive those values?
More information about the Python-list
mailing list