Giter Site home page Giter Site logo

facebook-group-scraper's Introduction

Facebook Group Scraper

A Facebook group scraper, highly inspired by kevinzg/facebook-scraper.

Written in Python 3.7. Not tested on other versions.

Install

Use this Scraper by git clone.

git clone https://github.com/wspooong/facebook-group-scraper.git
pip install -r requirements.txt

Usage

Here is an example of how to use this package:

from src.facebook_group_scraper import GroupScraper
import json
import logging

logging.basicConfig(level=logging.INFO)

scraper = GroupScraper(
    group_url="1260448967306807",
    page_cursor=None,
    fetch_comment=True,
    fetch_reply=True,
    page_sleep_secs=10,
    comment_sleep_secs=5,
    reply_sleep_secs=3,
)

for post in scraper.start():
    # Do something with the post
    with open("test.jsonl", "a+") as f:
        _ = f.write(json.dumps(post, ensure_ascii=False))
        _ = f.write("\n")

In the above code, group_url is the ID of the Facebook group you want to scrape. You can find this ID in the URL of the group's Facebook page.

page_cursor is used to paginate through the posts in the group. If page_cursor is None, the scraper will start from the most recent post and work its way backwards.

fetch_comment and fetch_reply are boolean values that determine whether or not to fetch comments and replies for each post. If set to True, the scraper will fetch all comments and replies for each post.

page_sleep_secs, comment_sleep_secs, and reply_sleep_secs are the number of seconds to sleep between each request. These values are useful for rate limiting your requests to Facebook's servers.

Testing

To run the tests, first install the necessary dependencies:

pip install pytest==7.2.2 responses

Then, run the tests:

pytest

Contributing

If you find any bugs or have any suggestions for this package, feel free to open an issue or a pull request on the GitHub repository.

Authors

  • Shih-Peng Wen - Initial work - website

See also the list of contributors who participated in this project.

facebook-group-scraper's People

Contributors

wspooong avatar

Stargazers

 avatar Bartosz Szymik avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.