Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random "Unable to find guest token" with TwitterUserScraper #325

Closed
palevell opened this issue Dec 10, 2021 · 3 comments
Closed

Random "Unable to find guest token" with TwitterUserScraper #325

palevell opened this issue Dec 10, 2021 · 3 comments
Labels
bug Something isn't working module:twitter

Comments

@palevell
Copy link

In the last few days, I have been getting Unable to find guest token exceptions with TwitterUserScraper.

I am running my code locally. The code retrieves user information for less than two dozen Twitter users. The error usually appears after 5 or 11 calls to TwitterUserScraper.

As a workaround, I applied a simple retry loop to my code, as follows:

import snscrape.modules.twitter as sntwitter
...
retries = 5
while retries > 0:
	try:
		result = sntwitter.TwitterUserScraper(twit, isUserId=False)
		...
		retries = -1
	except snscrape.base.ScraperException:
		if retries == 0:
			raise
		retries -= 1
		sleep(30)

Hopefully, this will help other users experiencing this issue.

@JustAnotherArchivist
Copy link
Owner

Yeah, I have also observed that occasionally since yesterday. I haven't spotted any patterns yet, and it's definitely happening more rarely for me than what you saw. Will investigate further on the weekend.

@JustAnotherArchivist JustAnotherArchivist added bug Something isn't working module:twitter labels Dec 10, 2021
@JustAnotherArchivist JustAnotherArchivist changed the title "Unable to find guest token" with TwitterUserScraper Random "Unable to find guest token" with TwitterUserScraper Dec 12, 2021
@JustAnotherArchivist
Copy link
Owner

Hopefully fixed by retrying the guest token retrieval in 525cd71.

@JustAnotherArchivist
Copy link
Owner

Post-mortem: Twitter started shifting the primary way they're handing out guest tokens to a different method in early December. The retries on the commit above helped as a crude workaround, but I have since added that other token retrieval method in commit 0336ce1, which should solve it properly, especially in combination with the token caching implemented in response to #326.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:twitter
Projects
None yet
Development

No branches or pull requests

2 participants