Treat Twitter responses without a Content-Type header as invalid (fixes #21)

This commit is contained in:
JustAnotherArchivist
2019-04-18 02:24:35 +02:00
parent 8458c12218
commit 73bc99596f

View File

@@ -27,7 +27,7 @@ class TwitterSearchScraper(snscrape.base.Scraper):
yield snscrape.base.URLItem(f'https://twitter.com/{username}/status/{tweetID}')
def _check_json_callback(self, r):
if r.headers['content-type'] != 'application/json;charset=utf-8':
if r.headers.get('content-type') != 'application/json;charset=utf-8':
return False, f'content type is not JSON'
return True, None