mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-17 13:58:11 +00:00
Fixed crash when timestamp is missing
This commit is contained in:
parent
cd66d00ca1
commit
4b4e73f69e
11
twoot.py
11
twoot.py
|
@ -146,9 +146,9 @@ def main(argv):
|
||||||
response = requests.get('https://twitter.com/' + twit_account, headers=headers)
|
response = requests.get('https://twitter.com/' + twit_account, headers=headers)
|
||||||
|
|
||||||
# DEBUG: Save page to file
|
# DEBUG: Save page to file
|
||||||
# of = open('twitter.html', 'w')
|
of = open('twitter.html', 'w')
|
||||||
# of.write(response.text)
|
of.write(response.text)
|
||||||
# of.close()
|
of.close()
|
||||||
|
|
||||||
# Verify that download worked
|
# Verify that download worked
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
|
@ -172,7 +172,10 @@ def main(argv):
|
||||||
author_logo_url = sih.find('img', class_='avatar')['src']
|
author_logo_url = sih.find('img', class_='avatar')['src']
|
||||||
|
|
||||||
# Extract time stamp
|
# 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
|
# Extract tweet id
|
||||||
tweet_id = sih.find('a', class_='tweet-timestamp')['href']
|
tweet_id = sih.find('a', class_='tweet-timestamp')['href']
|
||||||
|
|
Loading…
Reference in New Issue
Block a user