bisguzar / twitter-scraper

Scrape the Twitter Frontend API without authentication.
MIT License
3.88k stars 601 forks source link

KeyError: 'items_html' #164

Open vbandaru opened 3 years ago

vbandaru commented 3 years ago
for tweet in get_tweets("$AMD", pages=1):
  print(tweet['text'])

retruns error

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/twitter_scraper/modules/tweets.py in gen_tweets(pages)
     36                 html = HTML(
---> 37                     html=r.json()["items_html"], url="bunk", default_encoding="utf-8"
     38                 )

KeyError: 'items_html'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
2 frames
/usr/local/lib/python3.6/dist-packages/twitter_scraper/modules/tweets.py in gen_tweets(pages)
     39             except KeyError:
     40                 raise ValueError(
---> 41                     f'Oops! Either "{query}" does not exist or is private.'
     42                 )
     43             except ParserError:

ValueError: Oops! Either "$AMD" does not exist or is private.
koaly commented 3 years ago

having the same error.

tuchang commented 3 years ago

having the same error, but you used $ I used #

antick commented 3 years ago

I am facing the same issue.

It uses the following URL internally to fetch tweets:

https://twitter.com/i/search/timeline?f=tweets&vertical=default&q=%7Bquery%7D&src=tyah&reset_error_state=false&

And the above URL does not exist anymore.