hhsm95 / FacebookPostsScraper

Scraper for posts in Facebook user profiles, pages and groups
MIT License
140 stars 55 forks source link

CSV #2

Closed danielk56 closed 4 years ago

danielk56 commented 4 years ago

How would I be able to convert the results into a CSV file?

hhsm95 commented 4 years ago

It's really easy, you could do it with pandas Dataframe, just load the Dataframe with the result and export it as csv.

hhsm95 commented 4 years ago

Update to the latest commit, now you can export to CSV, Excel and JSON:

from FacebookPostsScraper import FacebookPostsScraper as Fps
from pprint import pprint as pp

# Enter your Facebook email and password
email = 'YOUR_EMAIL'
password = 'YOUR_PASWORD'

# Instantiate an object
fps = Fps(email, password, post_url_text='Full Story')

# Example with single profile
single_profile = 'https://www.facebook.com/BillGates'
fps.get_posts_from_profile(single_profile)

fps.posts_to_csv('my_posts')  # You can export the posts as CSV document
fps.posts_to_excel('my_posts')  # You can export the posts as Excel document
fps.posts_to_json('my_posts')  # You can export the posts as JSON document