Scrape Facebook public pages without an API key
Project description
Facebook Scraper
Scrape Facebook public pages without an API key. Inspired by twitter-scraper.
Install
pip install facebook-scraper
Usage
Send the unique page name as the first parameter and you're good to go:
>>> from facebook_scraper import get_posts
>>> for post in get_posts('nintendo', pages=1):
... print(post['text'][:50])
...
The final step on the road to the Super Smash Bros
We’re headed to PAX East 3/28-3/31 with new games
CLI usage
$ facebook-scraper --filename nintendo_page_posts.csv --pages 1 nintendo
Use
$ facebook-scraper --help
for more details on CLI usage
Optional parameters
- group: group id, to scrape groups instead of pages. Default is
None
. - pages: how many pages of posts to request, usually the first page has 2 posts and the rest 4. Default is 10.
- timeout: how many seconds to wait before timing out. Default is 5.
- sleep: how many seconds to sleep between each request. Default is 0.
- credentials: tuple of user and password to login before requesting the posts. Default is
None
. - extra_info: bool, if true the function will try to do an extra request to get the post reactions. Default is False.
- youtube_dl: bool, use Youtube-DL for (high-quality) video extraction. You need to have youtube-dl installed on your environment. Default is False.
Post example
{'post_id': '2257188721032235',
'text': 'Don’t let this diminutive version of the Hero of Time fool you, '
'Young Link is just as heroic as his fully grown version! Young Link '
'joins the Super Smash Bros. series of amiibo figures!',
'time': datetime.datetime(2019, 4, 29, 12, 0, 1),
'image': 'https://scontent.flim16-1.fna.fbcdn.net'
'/v/t1.0-0/cp0/e15/q65/p320x320'
'/58680860_2257182054366235_1985558733786185728_n.jpg'
'?_nc_cat=1&_nc_ht=scontent.flim16-1.fna'
'&oh=31b0ba32ec7886e95a5478c479ba1d38&oe=5D6CDEE4',
'likes': 2036,
'comments': 214,
'shares': 0,
'reactions': {'like': 135, 'love': 64, 'haha': 10, 'wow': 4, 'anger': 1}, # if `extra_info` was set
'post_url': 'https://m.facebook.com/story.php'
'?story_fbid=2257188721032235&id=119240841493711',
'link': 'https://bit.ly/something'}
Notes
- There is no guarantee that every field will be extracted (they might be
None
). - Shares doesn't seem to work at the moment.
- Group posts may be missing some fields like
time
andpost_url
. - Group scraping may return only one page and not work on private groups.
To-Do
- Async support
- Image galleries
- Profiles or post authors
- Comments
Alternatives and related projects
- facebook-post-scraper. Has comments. Uses Selenium.
- facebook-scraper-selenium. "Scrape posts from any group or user into a .csv file without needing to register for any API access".
- Ultimate Facebook Scraper. "Scrapes almost everything about a Facebook user's profile". Uses Selenium.
- Unofficial APIs. List of unofficial APIs for various services, none for Facebook for now, but might be worth to check in the future.
- major-scrapy-spiders. Has a profile spider for Scrapy.
- facebook-page-post-scraper. Seems abandoned.
- FBLYZE. Fork (?).
- RSSHub. Generates an RSS feed from Facebook pages.
- RSS-Bridge. Also generates RSS feeds from Facebook pages.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
facebook-scraper-0.2.12.tar.gz
(14.9 kB
view details)
Built Distribution
File details
Details for the file facebook-scraper-0.2.12.tar.gz
.
File metadata
- Download URL: facebook-scraper-0.2.12.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.7.19-2-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b1b6d4cd8cda32d862115b5f5ad779264303093b850251996e6fcffcc01826f |
|
MD5 | 551f99266c27478b1fb3d0a6f1fa70c0 |
|
BLAKE2b-256 | f2cc1ce9d89361a5c2a4657f8a32ddc5b00a7c86ebbbdc46f77718add31e237b |
File details
Details for the file facebook_scraper-0.2.12-py3-none-any.whl
.
File metadata
- Download URL: facebook_scraper-0.2.12-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.7.19-2-MANJARO
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d8b8a847587aa6f0297f866d0b02255485d1fb9bda1d4a12b7695a968736a66 |
|
MD5 | 6bd76f0dbab5734e3d898e359e8bd845 |
|
BLAKE2b-256 | aaacc21c68e9af3b92361df7a61a76a30c0f638a17b69c6434d9a1b3330f38f6 |