JustAnotherArchivist / snscrape

A social networking service scraper in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

snscrape KeyError: 'name'

shehzaf opened this issue · comments

The below code used to work a month back, but now it's returning the following error
869 if apiType is _TwitterAPIType.GRAPHQL and 'errors' in obj:
--> 870 msg = 'Twitter responded with an error: ' + ', '.join(f'{e["name"]}: {e["message"]}' for e in obj['errors'])
KeyError: 'name'

import snscrape.modules.twitter as sntwitter
tweets = []
query = "(GenerativeAI OR GenAI OR #GenAI OR #GenerativeAI) since:2023-01-01 until:2023-05-31"
for i, tweet in enumerate(sntwitter.TwitterSearchScraper(query).get_items()):
if i > 20000:
break
else:
tweets.append([tweet.date, tweet.id, tweet.url, tweet.user.username, tweet.sourceLabel, tweet.user.location, tweet.content, tweet.likeCount, tweet.retweetCount])

what do I change to correct this code?

Bro You're out of the loop so badly. Read the #996 to know what happened.

I have no idea how you could possibly be getting that error because yeah, no Twitter scraping works at all due to #996. If it's something different, please file a complete bug report.

Thanks much for the great work being done here @JustAnotherArchivist

I noticed twitter is now back to being public; as at the time I was awared Elon took it private, I could not see a copied tweet when pasted in a browser (where my twitter account is not logged in). But today, I noticed I can now see tweets publicly without logging in.

That prompted me to try the snstwitter scraper again and I got exactly the same error as @shehzaf

I am permutation Elon changed some things on the web, otherwise, our scrapers should be back working.