From 4bb4e31b48c419586d710e2a1003af8ac30bf7b8 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 27 Mar 2012 09:55:12 +0200 Subject: [PATCH] Handle Bing Preview and Chrome Mobile --- ox/text.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ox/text.py b/ox/text.py index 4d2fec2..eb20b5d 100644 --- a/ox/text.py +++ b/ox/text.py @@ -40,6 +40,7 @@ SUFFIXES = ['ii', 'iii', 'jr', 'jr.', 'ph.d.', 'phd', 'sr', 'sr.'] UA_ALIASES = { 'browser': { + 'Chrome': '(CrMo)', 'Firefox': '(Fennec|Firebird|Iceweasel|Minefield|Namoroka|Phoenix|SeaMonkey|Shiretoko)' }, 'system': { @@ -61,6 +62,7 @@ UA_NAMES = { } UA_REGEXPS = { 'browser': [ + '(BingPreview)\/(\d+)', '(Camino)\/(\d+)', '(chromeframe)\/(\d+)', '(Google Web Preview).+Chrome\/(\d+)', @@ -103,6 +105,7 @@ UA_REGEXPS = { '(Windows).+(WinNT4.0)' # Firefox ] } +UA_ROBOTS = ['BingPreview', 'Google Web Preview', 'Googlebot'] UA_VERSIONS = { 'browser': {}, 'system': { @@ -282,7 +285,7 @@ def parse_useragent(useragent): 'string': string } break; - data['robot'] = data['browser']['name'] in ['Google Web Preview', 'Googlebot'] + data['robot'] = data['browser']['name'] in UA_ROBOTS return data def removeSpecialCharacters(text):