Goodbye F12: session-capture — One Command to Grab Any Website's Auth Session
Tired of F12 → Application → Cookies → copy-paste-repeat? This open-source CLI tool captures your entire auth session — cookies, localStorage, CSRF tokens, and request headers — in a single command.
The Pain Every Developer Knows
Writing a scraper or automation script? You know the drill:
- Open DevTools (F12)
- Application tab → Cookies → find
session_id - Application tab → Local Storage → find
token - Network tab → dig through headers for
x-csrf-token - Copy
referer,user-agent... - Format, paste into
.env, pray you didn't miss anything
Five platforms = repeat five times. Cookie expires = repeat everything.
Existing tools don't help much:
| Tool | Cookies | localStorage | CSRF | Headers | CLI pipe | Persistent |
|---|---|---|---|---|---|---|
| session-capture | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| EditThisCookie | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
| browser_cookie3 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Manual DevTools | ✅ | Separate | Separate | Separate | ❌ | ❌ |
The real killer: many platforms (CSDN, Xiaohongshu, SegmentFault) need x-csrf-token, x-requested-with, and referer headers on top of cookies. Cookie-only tools are useless there.
session-capture: Full Auth Session, One Command
session-capture is an open-source CLI tool + Chrome extension that captures the entire authentication session state — everything a backend needs to authenticate a request.
pip install session-capture
playwright install chromium # one-time setup
capture capture https://dev.to
Here's what happens:
- A real browser window opens to dev.to
- You log in manually (secure — your password never touches the tool)
- Press Enter in your terminal
- Full session data captured:
{
"cookies": [
{"name": "session_id", "value": "abc123", "domain": ".dev.to"}
],
"localStorage": {
"token": "eyJhbG...",
"refresh": "xyz789"
},
"meta_csrf_token": "abc123def456",
"headers": {
"x-requested-with": "XMLHttpRequest",
"referer": "https://dev.to/settings",
"user-agent": "Mozilla/5.0 ..."
}
}
No more clicking through 4 DevTools tabs. One command, everything at once.
Four Output Formats for Every Workflow
# JSON — for programmatic use
capture capture https://dev.to
# Env — pipe straight to .env
capture capture https://dev.to --format env >> .env
# DEV_COOKIE="session_id=abc123;csrf=xyz"
# DEV_HEADERS="x-csrf-token:abc\nx-requested-with:XMLHttpRequest"
# DEV_LOCALSTORAGE='{"token":"abc"}'
# DEV_CSRF_TOKEN=abc123
# Netscape — for curl/wget
capture capture https://httpbin.org --format netscape > cookies.txt
curl -b cookies.txt https://httpbin.org/cookies
# Curl — single-line header
capture capture https://example.com --format curl
# → Cookie: name=value; name2=value2
Persistent Sessions: Login Once, Reuse Forever
This is where session-capture really shines. Every capture capture saves Playwright's storage_state — the full browser context including cookies, localStorage, sessionStorage, and IndexedDB.
Later:
# List saved sessions
capture list
# ┌──────────┬──────────────────────────────────────────────┐
# │ Name │ Storage Path │
# ├──────────┼──────────────────────────────────────────────┤
# │ dev_to │ ~/.session-capture/sessions/dev_to │
# │ juejin_cn│ ~/.session-capture/sessions/juejin_cn │
# └──────────┴──────────────────────────────────────────────┘
# Refresh without re-login
capture refresh dev_to --format env >> .env
Cookie expired? Just re-run refresh — your login state is still intact.
Chrome Extension Included
A companion Chrome extension is also available (pending Chrome Web Store review, can be loaded in dev mode):
- One-click export: cookies + localStorage + CSRF tokens from the current tab
- Format switching: JSON / Env / Netscape / Curl
- Copy to clipboard or download as file
Tech Stack
| Component | Tech | Why |
|---|---|---|
| CLI | Typer + Rich | Modern Python CLI, type-safe, beautiful output |
| Browser | Playwright | Context persistence, multi-engine (Chromium/Firefox) |
| Config | TOML | Human-readable, stdlib tomllib — zero extra deps |
| Extension | Chrome Manifest V3 | Web Store requirement |
| Testing | pytest | 49 tests, 90% coverage |
Key design decisions:
-
Headed browser, manual login — no touching encrypted cookie files, no fragile
browser_cookie3hacks. You log in. Secure. -
capture_session()as Python API — importable by other projects. No subprocess, no pipe parsing. agentcrew-mcn integrates it this way. - Single repo, dual component — CLI (Python) + extension (JS/HTML), zero coupling, CI with path filters.
- Cross-platform — macOS, Windows, Linux. Chromium and Firefox engines.
Comparison
| Feature | session-capture | EditThisCookie | browser_cookie3 |
|---|---|---|---|
| CLI pipe output | ✅ | ❌ | ✅ |
| Full session (cookies + localStorage + CSRF + headers) | ✅ | ❌ | ❌ |
| Persistent sessions | ✅ | ❌ | ❌ |
| Multi-format (JSON / env / Netscape / curl) | ✅ | JSON only | Custom |
| Cross-platform | ✅ | ✅ | ❌ (fragile) |
| Chrome extension | ✅ | ✅ | ❌ |
| No local cookie files | ✅ | N/A | ❌ |
| Python API (direct import) | ✅ | ❌ | ❌ |
| CI tested (49 tests) | ✅ | ❌ | ❌ |
Install & Links
pip install session-capture
# or with pipx:
pipx install session-capture
playwright install chromium
capture capture https://dev.to
- GitHub: github.com/super-rick/session-capture ⭐
- PyPI: pypi.org/project/session-capture/
- Chrome Web Store: Session Capture Exporter (under review)
MIT license. Stars, issues, and PRs welcome.
If you've ever cursed at F12 → Application → Cookies, try capture capture.
Top comments (0)