From b56475450de9a00a0ab12bfdf9adf9b5b229f38e Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 29 Apr 2022 23:12:41 +0200 Subject: [PATCH] Use utf-8 for cookies --- PFERD/crawl/http_crawler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PFERD/crawl/http_crawler.py b/PFERD/crawl/http_crawler.py index fa4cf29..44ec4dd 100644 --- a/PFERD/crawl/http_crawler.py +++ b/PFERD/crawl/http_crawler.py @@ -108,7 +108,7 @@ class HttpCrawler(Crawler): def _load_cookies_from_file(self, path: Path) -> None: jar: Any = http.cookies.SimpleCookie() - with open(path) as f: + with open(path, encoding="utf-8") as f: for i, line in enumerate(f): # Names of headers are case insensitive if line[:11].lower() == "set-cookie:": @@ -121,7 +121,7 @@ class HttpCrawler(Crawler): jar: Any = http.cookies.SimpleCookie() for morsel in self._cookie_jar: jar[morsel.key] = morsel - with open(path, "w") as f: + with open(path, "w", encoding="utf-8") as f: f.write(jar.output(sep="\n")) f.write("\n") # A trailing newline is just common courtesy