From 244aae1c9750224d4b7f36f811438827ecd672bc Mon Sep 17 00:00:00 2001 From: Shubham Talbar Date: Mon, 9 Oct 2023 20:13:40 -0700 Subject: [PATCH] Update project0.py --- scripts/project0.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/project0.py b/scripts/project0.py index 7bf7349..6b81c4a 100755 --- a/scripts/project0.py +++ b/scripts/project0.py @@ -181,8 +181,14 @@ def score(url): if response.status_code != 200: print(f"URL responded with non 200 status: {response.status_code}") return failures + 1 # Cannot continue - content = response.content.decode("utf-8") - + + try: + content = response.content.decode("utf-8") + except: + print("URL could not be decoded with utf-8 format") + print("Attempting to decode with utf-16 format") + content = response.content.decode("utf-16") + if response.history: print("URL redirected more than 0 times:") for history in response.history: