Detecting the browsers' name and version |
![]() |
Created by jmeile . Last modified 2004-05-13 14:44:46. |
Python script to detect browsers' name and version |
I took the original idea from: Determine Browser *type and improved it. The difference between the previous approach and mine is that I don't scan the HTTP_USER_AGENT string, I split it into several parts and store them in a list.
You just need the following python script: I know the code is ugly, but it's not my fault that agent strings aren't standard Calling it:
It will only work with Netscape >=4 (Somebody tested it with Ns 3.x and it worked), Microsoft Internet explorer, Opera, Galeon, K-Meleon >=0.7, Konqueror, lynx, links, wget and Mozilla/gecko compatible browsers. With the rest you will see browser='unknown', version='0'. If you want more browsers, you'll have to add them. Special thanks to:Volker Zausch for its idea of merging the two methods into one. Changes:* Mozilla-Geko browser returned the false version number (fixed).
If there is a bug or something is missing, please let me now:
|