minimaxir / facebook-page-post-scraper

Data scraper for Facebook Pages, and also code accompanying the blog post How to Scrape Data From Facebook Page Posts for Statistical Analysis
2.12k stars 666 forks source link

KeyError: 'next' = if there is no next page #97

Open bhagyashreeborate opened 6 years ago

bhagyashreeborate commented 6 years ago

I ran how_to_build_facebook_scrapper to get data from pages. The script is giving me all the results I want in csv file. But once all the pages are done and there is no next in statuses it gives me an error saying KeyError: 'next'

How can remove this error and get the last result saying %s Statuses Processed in %s.

wendyhu commented 6 years ago

You can just test if 'next' field exists in statuses dictionary, something like:

if 'paging' in statuses and next in statuses:

It should prevent to throw out error