adding encoding to default headers (itunes.py may supply others)
This commit is contained in:
parent
ca124a97f8
commit
adce03b134
1 changed files with 4 additions and 2 deletions
|
@ -9,12 +9,14 @@ import chardet
|
||||||
|
|
||||||
|
|
||||||
# Default headers for HTTP requests.
|
# Default headers for HTTP requests.
|
||||||
DEFAULT_HEADERS = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008041514 Firefox/3.0b5'}
|
DEFAULT_HEADERS = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008041514 Firefox/3.0b5',
|
||||||
|
'Accept-Encoding': 'gzip'
|
||||||
|
}
|
||||||
|
|
||||||
def openUrl(url, data=None, headers=DEFAULT_HEADERS):
|
def openUrl(url, data=None, headers=DEFAULT_HEADERS):
|
||||||
url = url.replace(' ', '%20')
|
url = url.replace(' ', '%20')
|
||||||
req = urllib2.Request(url, data, headers)
|
req = urllib2.Request(url, data, headers)
|
||||||
req.add_header('Accept-Encoding', 'gzip')
|
|
||||||
return urllib2.urlopen(req)
|
return urllib2.urlopen(req)
|
||||||
|
|
||||||
def getUrl(url, data=None, headers=DEFAULT_HEADERS):
|
def getUrl(url, data=None, headers=DEFAULT_HEADERS):
|
||||||
|
|
Loading…
Reference in a new issue