From 4b4e73f69ee0b1e57a1e27ccc112bbaf22befdbd Mon Sep 17 00:00:00 2001 From: JC Francois Date: Mon, 5 Aug 2019 20:18:36 +0200 Subject: [PATCH] Fixed crash when timestamp is missing --- twoot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/twoot.py b/twoot.py index 2a6da44..27072cc 100755 --- a/twoot.py +++ b/twoot.py @@ -146,9 +146,9 @@ def main(argv): response = requests.get('https://twitter.com/' + twit_account, headers=headers) # DEBUG: Save page to file - # of = open('twitter.html', 'w') - # of.write(response.text) - # of.close() + of = open('twitter.html', 'w') + of.write(response.text) + of.close() # Verify that download worked if response.status_code != 200: @@ -172,7 +172,10 @@ def main(argv): author_logo_url = sih.find('img', class_='avatar')['src'] # Extract time stamp - timestamp = sih.find('a', class_='tweet-timestamp').find('span', class_='_timestamp')['data-time'] + try: + timestamp = sih.find('a', class_='tweet-timestamp').find('span', class_='_timestamp')['data-time'] + except AttributeError: + continue # Extract tweet id tweet_id = sih.find('a', class_='tweet-timestamp')['href']