parent
918dede4be
commit
d3213ea1e7
5
morss.py
5
morss.py
|
@ -189,13 +189,14 @@ class HTMLDownloader(urllib2.HTTPCookieProcessor):
|
||||||
Custom urllib2 handler to download html pages, following <meta> redirects,
|
Custom urllib2 handler to download html pages, following <meta> redirects,
|
||||||
using a browser user-agent and storing cookies.
|
using a browser user-agent and storing cookies.
|
||||||
"""
|
"""
|
||||||
def __init__(self, cookiejar=None):
|
def __init__(self, useragent=UA_HML, cookiejar=None):
|
||||||
urllib2.HTTPCookieProcessor.__init__(self, cookiejar)
|
urllib2.HTTPCookieProcessor.__init__(self, cookiejar)
|
||||||
self.userAgent = UA_HML
|
self.useragent = useragent
|
||||||
|
|
||||||
def http_request(self, req):
|
def http_request(self, req):
|
||||||
urllib2.HTTPCookieProcessor.http_request(self, req)
|
urllib2.HTTPCookieProcessor.http_request(self, req)
|
||||||
req.add_header('Accept-Encoding', 'gzip')
|
req.add_header('Accept-Encoding', 'gzip')
|
||||||
|
req.add_header('User-Agent', self.useragent)
|
||||||
return req
|
return req
|
||||||
|
|
||||||
def http_response(self, req, resp):
|
def http_response(self, req, resp):
|
||||||
|
|
Loading…
Reference in New Issue