From 179c4f6880df1af19f025da7aee3f2a81b95a0fe Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 21 Aug 2025 13:38:23 -0700 Subject: skip twitch count scrape if request fails for any reason --- twitch.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/twitch.py b/twitch.py index 9ede9bb..bfce676 100644 --- a/twitch.py +++ b/twitch.py @@ -50,10 +50,12 @@ def get_total_follower_count_scrape(username: str) -> int: "Chrome/124.0.0.0 Safari/537.36" ) } - - response = requests.get(url, headers=headers, timeout=10) - response.raise_for_status() - html = response.text + try: + response = requests.get(url, headers=headers, timeout=10) + response.raise_for_status() + html = response.text + except: + return None soup = BeautifulSoup(html, 'html.parser') for li in soup.find_all("li", class_="list-group-item"): -- cgit v1.2.3