Handle Bing Preview and Chrome Mobile

This commit is contained in:
rolux 2012-03-27 09:55:12 +02:00
parent 1828701abd
commit 4bb4e31b48

View file

@ -40,6 +40,7 @@ SUFFIXES = ['ii', 'iii', 'jr', 'jr.', 'ph.d.', 'phd', 'sr', 'sr.']
UA_ALIASES = { UA_ALIASES = {
'browser': { 'browser': {
'Chrome': '(CrMo)',
'Firefox': '(Fennec|Firebird|Iceweasel|Minefield|Namoroka|Phoenix|SeaMonkey|Shiretoko)' 'Firefox': '(Fennec|Firebird|Iceweasel|Minefield|Namoroka|Phoenix|SeaMonkey|Shiretoko)'
}, },
'system': { 'system': {
@ -61,6 +62,7 @@ UA_NAMES = {
} }
UA_REGEXPS = { UA_REGEXPS = {
'browser': [ 'browser': [
'(BingPreview)\/(\d+)',
'(Camino)\/(\d+)', '(Camino)\/(\d+)',
'(chromeframe)\/(\d+)', '(chromeframe)\/(\d+)',
'(Google Web Preview).+Chrome\/(\d+)', '(Google Web Preview).+Chrome\/(\d+)',
@ -103,6 +105,7 @@ UA_REGEXPS = {
'(Windows).+(WinNT4.0)' # Firefox '(Windows).+(WinNT4.0)' # Firefox
] ]
} }
UA_ROBOTS = ['BingPreview', 'Google Web Preview', 'Googlebot']
UA_VERSIONS = { UA_VERSIONS = {
'browser': {}, 'browser': {},
'system': { 'system': {
@ -282,7 +285,7 @@ def parse_useragent(useragent):
'string': string 'string': string
} }
break; break;
data['robot'] = data['browser']['name'] in ['Google Web Preview', 'Googlebot'] data['robot'] = data['browser']['name'] in UA_ROBOTS
return data return data
def removeSpecialCharacters(text): def removeSpecialCharacters(text):