Skip to main content

Facebook GraphQL Scraper

Install

To install the latest release from PyPI:

pip install facebook-graphql-scraper

Requirements

ipython==8.19.0
pytz==2023.3.post1
selenium_wire==5.1.0

Support Me

If you enjoy this project and would like to support me, please consider donating 🙌
Your support will help me continue developing this project and working on other exciting ideas!

💖 Ways to Support:

Thank you for your support!! 🎉

Usage

You can choose between two methods to collect user posts data.

  • Pleas setup driver path at first
  • Log in with your account credentials: login facebook account
  • Without logging in: Without logging in, click the X icon to
  • Difference: The difference between these two methods is that for some personal accounts, you cannot browse the user's posts without logging into a Facebook account.
# -*- coding: utf-8 -*-
from fb_graphql_scraper.facebook_graphql_scraper import FacebookGraphqlScraper as fb_graphql_scraper


## Example.1 - without logging in
if __name__ == "__main__":
    facebook_user_name = "love.yuweishao"
    facebook_user_id = "100044253168423"
    days_limit = 20 # Number of days within which to scrape posts
    driver_path = "/Users/hongshangren/Downloads/chromedriver-mac-arm64_157/chromedriver" 
    fb_spider = fb_graphql_scraper(driver_path=driver_path, open_browser=False)
    res = fb_spider.get_user_posts(fb_username_or_userid=facebook_user_id, days_limit=days_limit,display_progress=True)
    # print(res)
    

Optional parameters

  • display_progress:
    A boolean value (True or False).
    If set to True, the scraper will display how many days of posts remain to be collected based on your days_limit.
    For example, if days_limit=180, it will scrape posts from today back to 180 days ago.
    During the process, the remaining days will be printed and decrease gradually until reaching 0 or below, at which point scraping stops.
    Example output:
    439 more days of posts to collect.

  • open_browser:
    If set to True, the scraper will launch a browser window.
    This allows login-based scraping (if fb_account and fb_pwd are provided), which may access more content.
    However, this mode consumes more memory and does not guarantee that your Facebook account will avoid being blocked.
    It is also useful for debugging if scraping fails or unexpected behavior occurs.

  • fb_username_or_userid:
    The Facebook Group ID, Fan Page ID, User ID, or User Name to scrape posts from.

  • days_limit:
    The number of days of posts to retrieve, counting backwards from today.

  • fb_account:
    Your Facebook account (Login-based scraping is still under maintenance.)

  • fb_pwd:
    Your Facebook account password (Login-based scraping is still under maintenance.)

Result example

{
  "fb_username_or_userid": "100044253168423",
  "profile": [
    "聯絡電話:0975-386-266",
    "Page",
    " · 演員",
    "hawa00328@gmail.com",
    "Not yet rated (3 reviews)",
    "\ufeff",
    "1,451,355 followers"
  ],
  "profile_picture": "https://scontent.ftpe7-3.fna.fbcdn.net/v/t39.30808-1/432384560_970902114394885_7123123077107726953_n.jpg?stp=dst-jpg_tt6&cstp=mx1080x1080&ctp=s720x720&_nc_cat=104&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=3ab345&_nc_ohc=C9GPTPyK0hwQ7kNvwHTFdFF&_nc_oc=AdrWDzntYtzvcmUOpRnpswB1JYapb0E4Wwx9ZCDJfrvnEwFIt9V0sIPLt7Xt7TNyMMs&_nc_zt=24&_nc_ht=scontent.ftpe7-3.fna&_nc_gid=CCybvl4ONI1JyrxIM5N9dw&_nc_ss=7f289&oh=00_AQSHf0MMg2v1TJCMz52vEHkdrTiVTwQhPTlaJxO9G3UWPw&oe=6AFAA4A3",
  "data": [
    {
      "post_id": "1687825662702523",
      "post_url": "https://www.facebook.com/1687825662702523",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-11-03 13:05:37",
      "published_date2": "2026-11-03",
      "time": 1793711137,
      "reaction_count.count": 2203,
      "comment_rendering_instance.comments.total_count": 24,
      "share_count.count": 12,
      "sub_reactions": {
        "讚": 2008,
        "大心": 189,
        "哈": 3,
        "加油": 2,
        "哇": 1
      },
      "context": "日常是…\n被duolingo 情勒 繼續練習語言、\n滑好笑reels滑太晚、\n把自己拔出沙發去洗澡、\n早上起床與棉被對抗。\n\n生活想要有趣、生活需要規律\n3C重度使用者要吃葉黃素,\n保護心血管又抗發炎要吃魚油。\n\n🌼金盞花葉黃素軟膠囊Plus\n🐟 日本原裝進口85%高OMEGA3魚油\n\n即日起至11/13(五) 11:00\n趁雙11優惠一次把康萃魚油葉黃素補齊吧\nbeezintw\nhttps://yaoyao.biz/sdgHq",
      "video_view_count": null
    },
    {
      "post_id": "1686457486172674",
      "post_url": "https://www.facebook.com/1686457486172674",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-11-02 04:06:42",
      "published_date2": "2026-11-02",
      "time": 1793592402,
      "reaction_count.count": 776,
      "comment_rendering_instance.comments.total_count": 12,
      "share_count.count": 4,
      "sub_reactions": {
        "讚": 686,
        "大心": 86,
        "哇": 3,
        "加油": 1
      },
      "context": "小編:粉潤對策是保養的基礎工程\n啟動好氣色\n這次日本味王在雙11準備了粉潤對策特別優惠,快塞滿你的購物車吧\n28 天明亮勻淨計劃,把光還給自己,讓陰影優雅消散。\nhttps://www.momoshop.com.tw/product/15653474\n\n#日本味王 #粉潤對策 #momo雙11",
      "video_view_count": null
    },
    {
      "post_id": "1681788199972936",
      "post_url": "https://www.facebook.com/1681788199972936",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-10-28 12:36:07",
      "published_date2": "2026-10-28",
      "time": 1793190967,
      "reaction_count.count": 1784,
      "comment_rendering_instance.comments.total_count": 14,
      "share_count.count": 5,
      "sub_reactions": {
        "讚": 1649,
        "大心": 124,
        "加油": 4,
        "哈": 4,
        "哇": 2,
        "怒": 1
      },
      "context": "今天的狀態,粉潤剛剛好!\n日本味王「粉潤對策」\n新廣告登場✨\n\n#日本味王 #粉潤對策",
      "video_view_count": null
    },
    {
      "post_id": "1680624306755992",
      "post_url": "https://www.facebook.com/1680624306755992",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-10-27 09:12:27",
      "published_date2": "2026-10-27",
      "time": 1793092347,
      "reaction_count.count": 3647,
      "comment_rendering_instance.comments.total_count": 43,
      "share_count.count": 43,
      "sub_reactions": {
        "讚": 3346,
        "大心": 285,
        "加油": 9,
        "哈": 3,
        "哇": 3,
        "嗚": 1
      },
      "context": "謝謝金鐘61🤍\n好值得收藏在記憶裡的一天\n\n👗louisvuitton #LouisVuitton\n💎bvlgari",
      "video_view_count": null
    },
    {
      "post_id": "1673892820762474",
      "post_url": "https://www.facebook.com/1673892820762474",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-10-20 11:00:42",
      "published_date2": "2026-10-20",
      "time": 1792494042,
      "reaction_count.count": 1283,
      "comment_rendering_instance.comments.total_count": 26,
      "share_count.count": 13,
      "sub_reactions": {
        "讚": 1118,
        "大心": 154,
        "哈": 5,
        "加油": 3,
        "哇": 2,
        "嗚": 1
      },
      "context": "第二年擔任MIXX平台的代言人\n滿心期待每個將送來的包裹\n\nMIXX雙十一將帶給大家更多質感選物\n快來跟我一起下單吧\n\n#MIXX #MIXX質感美學選物平台 #MIXX雙十一",
      "video_view_count": null
    },
    {
      "post_id": "1670182317800191",
      "post_url": "https://www.facebook.com/1670182317800191",
      "username_or_userid": "100044253168423",
      "owing_profile": {
        "__typename": "User",
        "name": "邵雨薇",
        "short_name": "邵雨薇",
        "id": "100044253168423"
      },
      "published_date": "2026-10-16 12:52:53",
      "published_date2": "2026-10-16",
      "time": 1792155173,
      "reaction_count.count": 8298,
      "comment_rendering_instance.comments.total_count": 110,
      "share_count.count": 236,
      "sub_reactions": {
        "讚": 7591,
        "大心": 649,
        "加油": 30,
        "哇": 17,
        "哈": 10,
        "嗚": 1
      },
      "context": "穿搭沒有標準答案,喜歡就好。\n\n除了衣服本身,我在意的\n還有那些讓整體更好看的小細節。\n穿出自己喜歡的樣子,就是最好的風格。\n@曼黛瑪璉  #雙弧\n\nhttps://bmai.app/c13bd4b5\n\n#曼黛瑪璉 #迷人雙弧 #挺美",
      "video_view_count": null
    }
  ]
}

Notes

  • If you choose to collect data by logging into your account, you may face the risk of your account being blocked, even if this program only scrolls through Facebook web pages.
  • Reaction Categories (EN): [like, haha, angry, love, care, wow, sad]
  • Reaction Categories (TW): [讚, 哈, 怒, 大心, 加油, 哇, 嗚]
## To-Do

- Login-based scraping

Metadata

Release files for facebook-graphql-scraper 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for facebook-graphql-scraper 1.2.1
File Size Uploaded Provenance Actions
facebook_graphql_scraper-1.2.1.tar.gz 25.4 kB Without provenance Details for facebook_graphql_scraper-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for facebook-graphql-scraper 1.2.1
File Interpreter ABI Platform Actions
facebook_graphql_scraper-1.2.1-py3-none-any.whl Python 3 none any Details for facebook_graphql_scraper-1.2.1-py3-none-any.whl

Total release size: 55.3 kB

Release files / facebook_graphql_scraper-1.2.1.tar.gz

Download URL facebook_graphql_scraper-1.2.1.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
513be9a56f5ac434fb602044d97dd5f8eb45fc5af62cf2cc1a09513e075be0d1
BLAKE2b-256 checksum
How to use checksums
f3a0388ebf99876aa162280b09dc0e75ad81581c93bc1bc3309185a3e1ec3919
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release files / facebook_graphql_scraper-1.2.1-py3-none-any.whl

Download URL facebook_graphql_scraper-1.2.1-py3-none-any.whl
Size 29.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8def1cf68cba54e50b0128e991263b0ff0f282da0f68bfde1edb982f54e070c3
BLAKE2b-256 checksum
How to use checksums
3a5de25b56d63de2f071b8e6cf594220e3e9b095af4241101e1cceb1b3d980f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Security for facebook-graphql-scraper 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page