Open TowardMyth opened 3 years ago
How do you know you're TemporarilyBanned if the code continues executing?
@neon-ninja The logger for facebook_scraper returns something like this:
2021-07-07 02:23:31,878 - facebook_scraper.extractors - ERROR - You’re Temporarily Blocked
.
As well, I added a print statement immediately before this line. This line gets printed to the console.
So one of the extract functions handles the error, but you're still able to fetch additional posts despite that? An individual extract function is considered non-critical, so handles exceptions gracefully. It's only if pagination threw an exception that it would be raised to your code.
@neon-ninja Is there any way to throw an exception even on individual extract functions? Or put another way, is there a way so that whenever I run into a "temporarilybanned" exception (whether it's on an individual extract function or pagination), my script can pause for 10+ mins before restarting?
@neon-ninja Thanks, your commit worked! A few more small questions:
time.sleep()
functions in between calls, etc?Have you been able to extract all the posts from a page with O(1k), O(10k), O(100k)
posts before?
Yes, I've done several CSV exports in the order of 1-5K per account. In https://github.com/kevinzg/facebook-scraper/issues/285, I extracted 14201 posts in 910s.
How do you know you're TemporarilyBanned if the code continues executing?
Hi Neon -ninja,
I m trying to scrap user posts for around 10 k users but facebook is temporarily blocking my account .Can you please suggest what can be the idea way to handle this.
I am scraping some FB pages.
FB temporarily bans you if you scrape too fast, and facebook-scraper will throw a
TemporarilyBanned exception
, per here.However, for some reason I'm unable to catch the
TemporarilyBanned exception
. The code below will continue executing - and not go to theExcept
block - even onceTemporarilyBanned Exception
is raised.The code below is inspired from @neon-ninja 's examples here.
How can I catch this exception, so that my scraper can wait for ~30+ mins before rescraping? Thanks!