HTTP::BrowserDetect - Determine the Web browser, version, and platform from an HTTP user agent string |
HTTP::BrowserDetect - Determine the Web browser, version, and platform from an HTTP user agent string
use HTTP::BrowserDetect;
my $browser = new HTTP::BrowserDetect($user_agent_string);
# Detect operating system if ($browser->windows) { if ($browser->winnt) ... if ($brorwser->win95) ... } print $browser->mac;
# Detect browser vendor and version print $browser->netscape; print $browser->ie; if (browser->major(4)) { if ($browser->minor() > .5) { ... } } if ($browser->version() > 4) { ...; }
# Process a different user agent string $browser->user_agent($another_user_agent_string);
The HTTP::BrowserDetect object does a number of tests on an HTTP user agent string. The results of these tests are available via methods of the object.
This module is based upon the JavaScript browser detection code available at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html.
You may also use a non-object-oriented interface. For each method, you may call HTTP::BrowserDetect::method_name(). You will then be working with a default HTTP::BrowserDetect object that is created behind the scenes.
user_agent($user_agent_string)
major($major)
minor($minor)
If passed a parameter, returns true if equals the minor version.
On occasion a version may have more than one decimal point, such as 'Wget/1.4.5'. The minor version does not include the second decimal point, or any further digits or decimals.
version($version)
beta($beta)
The following methods are available, each returning a true or false value. Some methods also test for the operating system version.
windows win16 win3x win31 win95 win98 winnt win32 win2k winme mac mac68k macppc os2 unix sun sun4 sun5 suni86 irix irix5 irix6 hpux hpux9 hpux10 aix aix1 aix2 aix3 aix4 linux sco unixware mpras reliant dec sinix freebsd bsd vms amiga
It may not be possibile to detect Win98 in Netscape 4.x and earlier. On Opera 3.0, the userAgent string includes ``Windows 95/NT4'' on all Win32, so you can't distinguish between Win95 and WinNT.
os_string()
Win95, Win98, WinNT, Mac, Win3x, OS2, Unix, Linux
The following methods are available, each returning a true or false value. Some methods also test for the browser version, saving you from checking the version separately.
netscape nav2 nav3 nav4 nav4up nav45 nav45up navgold nav6 nav6up gecko ie ie3 ie4 ie4up ie5 ie55 neoplanet neoplanet2 mosaic aol aol3 aol4 aol5 aol6 webtv opera lynx emacs staroffice lotusnotes icab konqueror java
Netscape 6, even though its called six, in the userAgent string has version number 5. The nav6 and nav6up methods correctly handle this quirk.
browser_string()
Netscape, MSIE, WebTV, AOL Browser, Opera, Mosaic, Lynx
The following methods are available, each returning a true or false value.
wap audrey iopener palm avantgo
robot()
The following additional methods are available, each returning a true or false value. This is by no means a complete list of robots that exist on the Web.
wget getright yahoo altavista lycos infoseek lwp webcrawler linkexchange slurp google
Lee Semel, lee@semel.net
``The Ultimate JavaScript Client Sniffer, Version 3.0'', http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html.
perl(1), the HTTP::Headers manpage, the HTTP::Headers::UserAgent manpage.
Copyright 1999-2001 Lee Semel. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
HTTP::BrowserDetect - Determine the Web browser, version, and platform from an HTTP user agent string |