From 53d7dcdc93fe6361c5f4c23460752ef966a6544a Mon Sep 17 00:00:00 2001 From: JCF Date: Mon, 12 Feb 2024 12:17:03 +0000 Subject: [PATCH] Catch exception on bad nitter page --- twoot.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/twoot.py b/twoot.py index 6739f70..803dd1c 100755 --- a/twoot.py +++ b/twoot.py @@ -539,9 +539,9 @@ def build_config(args): options = { 'nitter_instances': [ 'n.opnxng.com', # added 10/11/2023 - 'nitter.ktachibana.party', # added 01/11/2023 'nitter.mint.lgbt', # added 09/02/2024 'nitter.1d4.us', # added 09/02/2024 + # 'nitter.ktachibana.party', # added 01/11/2023 # 'nitter.x86-64-unknown-linux-gnu.zip', # down 09/02/2024 # 'nitter.tinfoil-hat.net', # down 09/02/2024 # 'nitter.eu.projectsegfau.lt', # down 14/11/2023 @@ -687,8 +687,13 @@ def get_timeline(session, nitter_url): tl = soup.find('div', class_='timeline') # Get the list of direct children of timeline - list = tl.find_all('div', recursive=False) - + try: + list = tl.find_all('div', recursive=False) + except AttributeError: + logging.fatal('The Nitter page ' + url + ' does not include the expected content') + logging.fatal(twit_account_page.text) + shutdown(-1) + timeline = [] for item in list: classes = item['class']