kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.43k stars 631 forks source link

Extra-info return 0 #271

Closed TranNgocChinh closed 3 years ago

TranNgocChinh commented 3 years ago

When I scrape a post, the like, comment, share, reaction count is returned 0 although I changed extra_info to True. Any help?

neon-ninja commented 3 years ago

Hi, what post are you having this problem with? And what version of facebook-scraper?

neon-ninja commented 3 years ago

This commit (https://github.com/kevinzg/facebook-scraper/commit/ae952aa32e7e9c421fb639200be9490d7de23bb0) might help, try update and see if that fixes it

TranNgocChinh commented 3 years ago

This commit (ae952aa) might help, try update and see if that fixes it

Thanks, @neon-ninja, it's work for:

- likes: is NOT, it still returns 0.

You can check this post_id 3562752130402557 Thanks

neon-ninja commented 3 years ago
posts = get_posts(
    post_urls=[3562752130402557],
    extra_info = True,
    cookies = "cookies.txt"
)

for post in posts:
    print(post["likes"], post.get("reactions"))

gives

102 {'like': 102, 'love': 17, 'haha': 3, 'wow': 1, 'care': 1}
TranNgocChinh commented 3 years ago

I use the CLI command: facebook-scraper 3562752130402557 -f hihi.csv --encoding utf-8

gives blank at "likes": https://ibb.co/wCphWG5

Can you add total_reactions? Etc: total_reactions: 124 102 {'like': 102, 'love': 17, 'haha': 3, 'wow': 1, 'care': 1}

Thanks

neon-ninja commented 3 years ago

You might need to update with pip install -U facebook-scraper - this worked for me


facebook-scraper 3562752130402557 -f hihi.csv --encoding utf-8
/usr/local/lib/python3.8/dist-packages/facebook_scraper/facebook_scraper.py:235: UserWarning: Locale detected as en_GB - for best results, set to en_US
  warnings.warn(f"Locale detected as {locale} - for best results, set to en_US")
csvtool namedcol likes hihi.csv 
likes
102
neon-ninja commented 3 years ago

This commit should surface the total reaction count - https://github.com/kevinzg/facebook-scraper/commit/490da54bff34c7855dd05af2f861e2ac1e7a785a

TranNgocChinh commented 3 years ago

Hi, Likes count is OK now. I updated the new commit and set extra_info = true, but it gives blank on "reactions" and "reaction_count", pls check it: https://ibb.co/Lz7thQJ

neon-ninja commented 3 years ago

You'll need to specify that you want reactions - are you using Python or the CLI? As of https://github.com/kevinzg/facebook-scraper/commit/3bf368722710bdd6a40279bf340f49eaaa6f1bf0, you can pass the argument --reactions to the CLI command

TranNgocChinh commented 3 years ago

I'm using CLI. Updated, but still get blank on "reactions" and "reaction_count"

bash-3.2$ facebook-scraper 3562752130402557 -f hihi.csv --encoding utf-8 --reactions /Users/ngocchinh/.local/share/virtualenvs/InfoSec-xnhezEcJ/lib/python3.8/site-packages/facebook_scraper/facebook_scraper.py:235: UserWarning: Locale detected as vi_VN - for best results, set to en_US warnings.warn(f"Locale detected as {locale} - for best results, set to en_US")

neon-ninja commented 3 years ago

You probably also need to pass cookies with the --cookies CLI argument. See the readme for instructions on how to extract cookies.