From: Alexander Cecile Date: Tue, 18 Aug 2020 23:36:47 +0000 (-0400) Subject: Tell requests to detect encoding. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=79bd7d4122077bbd5fd9721b7c528596664bdf97;p=stevenblack-hosts.git Tell requests to detect encoding. Changed the get_file_by_url function to infer/guess the encoding of the content we receive. --- diff --git a/updateHostsFile.py b/updateHostsFile.py index 3e2b00185..b8d64a29c 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -1467,7 +1467,9 @@ def maybe_copy_example_file(file_path): def get_file_by_url(url, params, **kwargs): - return requests.get(url=url, params=params, **kwargs).text + req = requests.get(url=url, params=params, **kwargs) + req.encoding = req.apparent_encoding + return req.text def write_data(f, data):