missing ext

While doing some long term data collection I found some user objects
that lack the key 'ext'. This would cause an exception unless it's
checked for before trying to dig out results.
This commit is contained in:
Ed Summers
2021-09-16 13:31:47 -04:00
parent a11eef6b06
commit 9831f2a4a0

View File

@@ -459,7 +459,7 @@ class TwitterAPIScraper(snscrape.base.Scraper):
kwargs['linkTcourl'] = user.get('url')
kwargs['profileImageUrl'] = user['profile_image_url_https']
kwargs['profileBannerUrl'] = user.get('profile_banner_url')
if 'label' in user['ext']['highlightedLabel']['r']['ok']:
if 'ext' in user and 'label' in user['ext']['highlightedLabel']['r']['ok']:
kwargs['label'] = user['ext']['highlightedLabel']['r']['ok']['label']['description']
kwargs['labelUrl'] = user['ext']['highlightedLabel']['r']['ok']['label']['url']['url']