fix utf-8 urls
This commit is contained in:
parent
5936bc0de0
commit
2d467ea6c6
1 changed files with 6 additions and 2 deletions
|
@ -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 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')
|
||||
|
|
Loading…
Reference in a new issue