Use less suspicious user-agents.

master
pictuga 2013-05-01 17:54:17 +02:00
parent 0a97a2a2b5
commit 2f1ae1ce91
1 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,9 @@ MAX = 70
DELAY=10 DELAY=10
TIMEOUT = 2 TIMEOUT = 2
UA_RSS = 'Liferea/1.8.12 (Linux; fr_FR.utf8; http://liferea.sf.net/)'
UA_HML = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11'
ITEM_MAP = { ITEM_MAP = {
'link': (('{http://www.w3.org/2005/Atom}link', 'href'), '{}link'), 'link': (('{http://www.w3.org/2005/Atom}link', 'href'), '{}link'),
'desc': ('{http://www.w3.org/2005/Atom}summary', '{}description'), 'desc': ('{http://www.w3.org/2005/Atom}summary', '{}description'),
@ -243,6 +246,7 @@ def EncDownload(url):
try: try:
cj = CookieJar() cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-Agent', UA_HML)]
con = opener.open(url, timeout=TIMEOUT) con = opener.open(url, timeout=TIMEOUT)
data = con.read() data = con.read()
except (urllib2.HTTPError, urllib2.URLError) as error: except (urllib2.HTTPError, urllib2.URLError) as error:
@ -329,7 +333,7 @@ def Gather(url, cachePath):
else: else:
try: try:
req = urllib2.Request(url) req = urllib2.Request(url)
req.add_unredirected_header('User-Agent', 'Liferea/1.8.12 (Linux; fr_FR.utf8; http://liferea.sf.net/)') req.add_unredirected_header('User-Agent', UA_RSS)
xml = urllib2.urlopen(req).read() xml = urllib2.urlopen(req).read()
cache.set(url, xml) cache.set(url, xml)
except (urllib2.HTTPError, urllib2.URLError): except (urllib2.HTTPError, urllib2.URLError):