Grabbing user's agent and OS type

Νικόλαος Κούρας nikos.kouras at gmail.com
Fri Mar 11 10:59:18 EST 2011


Thanks a lot Steven!

The following code worked like a charm!

******************
agent = os.environ['HTTP_USER_AGENT']

# determination of user browser
agent = agent.lower()
if 'chrome' in agent:
	agent = 'Chrome'
if 'firefox' in agent:
	agent = 'Firefox'
if 'opera' in agent:
	agent = 'Opera'
if 'safari' in agent:
	agent = 'Safari'
if 'msie' in agent:
	agent = 'IE'
***************

I just want to have an idea of what browser a guest is using when
hitting my webpage.

http://www.superhost.gr/?show=log

now includes also that filed in the logging process.

But if i wanted the OS also?

sys.platform is for retrieving the host OS type that the script is
running and not the guest OS type.



More information about the Python-list mailing list