kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.35k stars 626 forks source link

I added {"reactions":True} but doesn't return reactions #608

Open gurkanbekdemir opened 2 years ago

gurkanbekdemir commented 2 years ago

Hi,

I added reactions in options but doesn't return reactions.

System info; Python 3.9.6 facebook-scraper==0.2.49 (higher versions give lz4 install error)

from facebook_scraper import get_posts
import json

post_url = 'story.php?story_fbid=1116068529136708&id=100022007147598&m_entstream_source=timeline&anchor_composer=false'
option_config = {"comments": True , "reactions": True}

with open("data.json", "w") as f:
    posts = list(get_posts(post_url, options=option_config, extra_info=True))
    json.dump(posts, f, indent=4, default=str)

Thanks

neon-ninja commented 2 years ago

Reaction extraction requires you to pass cookies, try pass cookies as per the readme. Reaction extraction for this post is working fine for me in both v0.2.49 and latest master with cookies. The code

post_url = 'story.php?story_fbid=1116068529136708&id=100022007147598&m_entstream_source=timeline&anchor_composer=false'
post = next(get_posts(post_urls=[post_url], cookies="cookies.json", options={"reactions": True}))
print(post["reactions"])

outputs:

{'like': 267, 'love': 26, 'care': 1}

https://github.com/kevinzg/facebook-scraper/commit/eb2af83c90ae18fc10dae3ed0d5a881790657ed5 updates the README to make this clearer.

gurkanbekdemir commented 2 years ago

That worked! Thank you. I appreciate you.