moda20 / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
88 stars 28 forks source link

How to limit results to posts only? #23

Closed ryanbuckner closed 7 months ago

ryanbuckner commented 11 months ago

I'm trying to get a list of posts from a page. The results include likes, and profile info and locations and #comments. I just want the posts

Here's my code:

from facebook_scraper import facebook_scraper
for post in get_posts('ryanbuckner', pages=20, credentials=['myusername@user.com','passwordgoeshere']):
  print(post['post_text'][:50])

results:

| Check out this fun fundraising initiative taking place at Alana's school. All of the students will be running laps on March 11th to raise money for the PTA to support programs for the students. If you'd like to make a pledge the information is below.
| MYBOOSTER.COM
| Check out this video of Alana making a big impact through this year's school fundraiser. Please make a donation to keep the momentum going!
| We are raising funds for instructional & enrichment programs for students, teacher support, PTA activities, & field trips in the Forestville Cardinal Boosterthon. Click here to help us: https://mybooster.com/v3/dash/Ykl2_p1m
| Harvey and 3 others
| 2 comments
| Like
| Show more reactions
| Comment
| Share
| Dawn is with Ryan.
| March 4, 2022 at 9:52 AM ·
| More options
| Welcome to the family Mel, short for Melvin the Melon. Enjoy your brief stay with us until we eat you today! #kids
| Alice and 9 others
| Like
| Show more reactions
| Comment
| Share
| Ryan
| March 3, 2022 at 8:17 PM ·
| More options
| If you chose not to have children, sure you have unlimited time and expendable cash. But who leads your Melon Personification Department eh? #suckas
| Jon and 10 others
| Like
| Show more reactions
| Comment
| Share
| Ryan
| February 28, 2022 at 6:30 AM ·
| More options
| I’ve been volunteering with Lasagna Love for a little over a year now and since then the movement has grown to 3 countries and over 25,000 volunteers impacting over 600,000 people. If you or someone you know could use a hand with dinner, for any reason, consider a request here.
| LASAGNALOVE.ORG
| Request - Lasagna Love
| Do you or a friend need a hand with dinner? Kindness is for everyone. No matter the reason for the need, your community wants to help. Let a neighbor deliver a home-cooked lasagna or main dish to your family one night. We currently have chefs cooking in the United States, Puerto Rico, Canada, and Au...
| Eric and 10 others
| 3 comments
| Like
| Show more reactions
| Comment
| Share+------------------------------------------------------------
moda20 commented 11 months ago

@ryanbuckner the extracted dictionary has more than just post_text, check other keys like shared_text, text, or full_text (only returned if the post text is longer than the list's maxcharacter point), and see if they fulfill your needs.

moda20 commented 7 months ago

@ryanbuckner

we now have 2 ways of controlling what to scrape, the whitelist_methods option and the HQ_images, you can check them on the documentation.

On that i am closing this issue