Maybe this helps. In my experience more than extracting the details of the browser string I have analyzed the follow things:
1) Detect if is a Crawler/ Bot
This will help you to diferenciate the true users from bot visits.
def is_crawler?(agent)
testv=false
testm=false
case agent
when /Slurp/,/Sitemaps/, /Mediapartners-Google/, /VoilaBot/ ,
/Googlebot/, /Spider/, /msnbot/,
/SnapPreviewBot/, /ichiro/, /Jeeves/,
/Baidu/, /CazoodleBot/, /Crawler/,/Pagebull/,/shel
/Gigabot/, /libwww-perl/, /lwp-trivial/,/SiteUptime/
/FeedHub/, /SimplePie/, /Yeti/, /AideRSS/, /Sogou/, /Gaisbot/,/robot/, /crawler/ ,/curl/, /LeapTag/, /Java/,/Moreoverbot/,
/Feedfetcher/,/attributor/
testv = true
end
case agent
when /Mozilla/
#Verify if Mozilla is present in the agent
testm=true
end
if testm==true and testv==false then
case agent
when /Opera/
testm=false
end
end
#if mozilla isn't present and is not crawler. Make it crawler.
if testm==false and testv==false then
testv=true
end
return testv
end
2) Detect if is a mobile browser
def is_mobile(agent)
testv=false
if not is_crawler(agent) then
case agent
when /Nokia/, /AvantGo/, /DoCoMo/,
/Vodafone/, /PalmOS/, /Windows CE/,
/Minimo/, /Plucker/, /Palmsource/,
/NetFront/, /PIE/, /iPhone/,
/BlackBerry/, /MOT-/, /Nokia/,
/Symbian/, /O2/, /Mini/,
/Blazer/, /MobileExplorer/, /RegKing/,
/EPOC/, /SAGEM/, /SCH-/,
/SGH/, /SonyEricsson/,
/Tablet/
testv= true
else
testv= false
end
else
testv=false
end
return testv
end
Hopem this practical use helps.
Main Topics
Browse All Topics





by: netbuzzPosted on 2009-08-29 at 19:25:22ID: 25216154
JavaScript code to detect browser vendor, version, and Operating System: http://www.creaweb.fr/DHTM L/faq/brow ser.html
Fo r language detection: http://forums.digitalpoint .com/showp ost.php?p= 5946242& po stcount=3