fix utf-8 urls

This commit is contained in:
j 2014-10-06 08:22:25 +02:00
parent 5936bc0de0
commit 2d467ea6c6

View file

@ -52,8 +52,12 @@ def get_json(url, data=None, headers=DEFAULT_HEADERS):
return json.loads(read_url(url, data, headers).decode('utf-8'))
def open_url(url, data=None, headers=DEFAULT_HEADERS):
if isinstance(url, bytes):
url = url.decode('utf-8')
if PY3:
if isinstance(url, bytes):
url = url.decode('utf-8')
else:
if not isinstance(url, bytes):
url = url.encode('utf-8')
url = url.replace(' ', '%20')
if data and PY3 and not isinstance(data, bytes):
data = data.encode('utf-8')