Headless social media toolkit for AI agents โ 9 platforms, cookie-based auth, paste-and-send.
Project description
๐ช Social Cookie Jar
Headless social media automation toolkit for AI agents. Cookie-based auth, paste-and-send pattern, zero typing detection.
Supported Platforms
| Platform | Feed | Post | Comment | Reply | Like |
|---|---|---|---|---|---|
| โ | โ | โ | โ | โ | |
| Twitter/X | โ | โ | โ | โ | โ |
| โ | โ | โ | โ | โ | |
| โ | โ | โ | โ | โ | |
| Discord | โ | โ | โ | โ | โ |
| โ | โ | โ | โ | โ | |
| Hacker News | โ | โ | โ | โ | โ |
| Substack | โ | โ | โ | โ | โ |
| PyPI | โ | โ | โ | โ | โ |
How It Works
- Login once in a real browser (or use the CDP cookie export)
- Export cookies to a pickle/JSON file
- Selenium loads cookies โ no login flow, no 2FA, no CAPTCHA
- Paste-and-send โ text is pasted via
ClipboardEvent, not typed character by character. Instant and indistinguishable from human behavior.
Install
pip install social-cookie-jar
# or
pip install -e .
Requires: Python 3.10+, Chrome/Chromium, ChromeDriver
Quick Start
Export cookies from a running browser (CDP)
from social_cookie_jar import export_from_cdp
# From an OpenClaw/Playwright/Puppeteer browser with CDP enabled
export_from_cdp("ws://127.0.0.1:9222/devtools/page/TARGET_ID", "facebook", "./cookies")
Use a driver
from social_cookie_jar import TwitterDriver
with TwitterDriver(cookie_dir="./cookies") as tw:
if tw.login():
tw.post("Hello from an AI agent ๐ค")
for tweet in tw.feed():
print(tweet.text[:100])
tw.reply("https://x.com/user/status/123", "Great thread!")
CLI
# Login check
python -m social_cookie_jar login twitter
# Post
python -m social_cookie_jar post twitter "Hello world"
python -m social_cookie_jar post facebook "My first post"
# Read feeds
python -m social_cookie_jar feed reddit LocalLLaMA
python -m social_cookie_jar feed hackernews
# Comment
python -m social_cookie_jar comment facebook https://fb.com/post/123 "Nice post!"
python -m social_cookie_jar reply twitter https://x.com/user/status/123 "Interesting!"
# Submit to HN
python -m social_cookie_jar submit hackernews "Show HN: My Project" --url https://myproject.com
# Export cookies
python -m social_cookie_jar export-cookies facebook --cdp-url ws://127.0.0.1:9222/devtools/page/ID
python -m social_cookie_jar export-cookies twitter --json-file cookies.json
Architecture
social_cookie_jar/
โโโ __init__.py # Package exports
โโโ __main__.py # CLI entry point
โโโ cookie_jar.py # CookieJar โ save/load/inject cookies (pickle + JSON)
โโโ export.py # CDP, Playwright, JSON, Netscape cookie import
โโโ drivers/
โโโ __init__.py # BaseDriver โ shared Selenium utilities + paste pattern
โโโ facebook.py # FacebookDriver
โโโ twitter.py # TwitterDriver
โโโ linkedin.py # LinkedInDriver
โโโ reddit.py # RedditDriver
โโโ discord.py # DiscordDriver
โโโ instagram.py # InstagramDriver
โโโ hackernews.py # HackerNewsDriver
โโโ substack.py # SubstackDriver
โโโ pypi.py # PyPIDriver
Key Design Decisions
- Cookie-based auth โ no passwords stored or typed into browsers. Export cookies once from a real session, reuse forever (until they expire).
- Paste, don't type โ
ClipboardEventpaste is instant and bypasses typing-speed heuristics. This is how humans actually work (Ctrl+V). - Platform-specific drivers โ each platform has its own CSS selectors and flow. No generic "just find a textbox" approach.
- Headless by default โ no GUI needed. Perfect for servers, CI, AI agent runtimes.
Cookie Refresh
Cookies expire (typically 30-90 days). When they do:
- Login manually in a regular browser
- Re-export cookies:
python -m social_cookie_jar export-cookies <platform> --cdp-url <url> - Selenium picks up new cookies automatically
For AI Agents
This toolkit is designed for AI agents that need social media presence. See llms.txt in this repo for AI-specific guidance.
Separation pattern: Use your host browser for human accounts, and Social Cookie Jar (Selenium) for the agent's own accounts. Never mix sessions.
License
MIT โ see LICENSE
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file
social_cookie_jar-0.2.0.tar.gz.File metadata
File hashes
8d4a34f64ba454beb27ad5b411218072f935ccd97736c0b9a385f58290e7754351e5557e37baad82610b1e8d270435d8245a14d8bea03a865a44b8df60ea96e5728926a5bb7f36dcc37cff3a77356effSee more details on using hashes here.