From 076552c01320bb10ba2dc622c51d2075178cc8f9 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 29 Mar 2016 21:05:07 +0100 Subject: added code to Utils.get_url to prevent non-iso-latin-1 urls being attempted. I need to put in a better fix than this at some point. --- Utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utils.py b/Utils.py index 175c3ac7..f3363c5a 100644 --- a/Utils.py +++ b/Utils.py @@ -37,6 +37,12 @@ def get_url(url, **kwargs): if post_params: post_params = urllib.parse.urlencode(post_params).encode("utf8") url = "%s%s" % (url, get_params) + try: + url.encode("latin-1") + except UnicodeEncodeError: + if kwargs.get("code"): + return 0, False + return False request = urllib.request.Request(url, post_params) request.add_header("Accept-Language", "en-US") -- cgit v1.3.1-10-gc9f91