kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.3k stars 618 forks source link

IndexError: list index out of range #215

Open cmutts opened 3 years ago

cmutts commented 3 years ago

I am using Facebook-scraper to get posts from my Facebook page and post them to Instagram using python. I am using telegram-Facebook-pages-bot. However, the Facebook scraper is giving me this error: call last): File "scraper.py", line 49, in check() File "scraper.py", line 43, in check page['last_post_used'] = posts[-1]['time'] IndexError: list index out of range.

neon-ninja commented 3 years ago

You should update your code to check if there aren't any posts (if not posts or if len(posts) == 0), and handle the error accordingly

VariabileAleatoria commented 3 years ago

You should update your code to check if there aren't any posts (if not posts or if len(posts) == 0), and handle the error accordingly

that is for sure right but why does the function return 0 posts? Shouldn't that happen only on pages that haven't posted once in a lifetime?

neon-ninja commented 3 years ago

You should update your code to check if there aren't any posts (if not posts or if len(posts) == 0), and handle the error accordingly

that is for sure right but why does the function return 0 posts? Shouldn't that happen only on pages that haven't posted once in a lifetime?

It's possible that you're temporarily IP banned, try feed in cookies as per the Readme