kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.45k stars 633 forks source link

Use facebook_scraper to exact posts, comments based on hashtag on a certain date #1096

Open ZheyiXu opened 7 months ago

ZheyiXu commented 7 months ago

I am new to Python and trying to use facebook_scraper to collect data.

import facebook_scraper as fs

HASHTAGID = "theone"

MAX_COMMENTS = 10

MAX_POSTS = 10

gen = fs.get_posts(
    hashtag=HASHTAGID,
    options={"comments": MAX_COMMENTS, "progress": True, "time": datetime.date(2016,8,4)}
)

post = next(gen)
comments = post['comments_full']

But I receive error message below

---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)
<ipython-input-35-88c9d27c2318> in <module>
     10 )
     11 
---> 12 post = next(gen)
     13 #comments = post['comments_full']
     14 

StopIteration: 

How should I revise the code?