mirror of
https://github.com/soimort/you-get.git
synced 2025-02-10 12:12:26 +03:00
fix UnicodeEncodeError
This commit is contained in:
parent
5cdbbd9291
commit
d53fba51a7
@ -148,12 +148,17 @@ def undeflate(data):
|
||||
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
|
||||
return decompressobj.decompress(data)+decompressobj.flush()
|
||||
|
||||
|
||||
# DEPRECATED in favor of get_content()
|
||||
def get_response(url, faker = False):
|
||||
def get_response(url, faker=False):
|
||||
if faker:
|
||||
response = request.urlopen(request.Request(url, headers = fake_headers), None)
|
||||
response = request.urlopen(request.Request(url, headers=fake_headers), None)
|
||||
else:
|
||||
response = request.urlopen(url)
|
||||
try:
|
||||
response = request.urlopen(url)
|
||||
except UnicodeEncodeError:
|
||||
url = url.encode('ascii', 'ignore').decode('ascii')
|
||||
response = request.urlopen(url)
|
||||
|
||||
data = response.read()
|
||||
if response.info().get('Content-Encoding') == 'gzip':
|
||||
|
Loading…
Reference in New Issue
Block a user