fixed exception when no hashtag is present

master
Domeniko Gentner 4 years ago
parent 0ba324a373
commit ce92f432e2
  1. 11
      twitter/twitter.py

@ -51,9 +51,14 @@ class twitter:
r = requests.get(url=get_url, headers=header)
r.raise_for_status()
excluded = r.json()[0]['entities']['hashtags'][0]['text']
if excluded in self.credentials['exclude']:
exit(0)
try:
excluded = r.json()[0]['entities']['hashtags'][0]['text']
if excluded in self.credentials['exclude']:
exit(0)
except IndexError:
# No hashtags, that's fine
pass
return r.json()[0]
except Exception as e:

Loading…
Cancel
Save