简介
x-twitter-browser
原始描述
Log in to X/Twitter via a real browser session and perform actions — posting, replying, reposting, liking, and bookmarking tweets via headless Playwright.
通过你的 Agent 添加
点「快速安装」复制一段指令,粘给你正在用的 Agent(Claude Code、Codex、OpenClaw 等),它会自己完成安装。
或者手动安装
包里是 SKILL.md 加作者附带的文件,解压后目录名就是技能名。
技能申请的权限由作者决定,装之前请确认它能读什么、能执行什么。
技能正文
name: x-twitter-browser description: Use a real browser session's cookie header to verify login and perform browser actions on X/Twitter via headless Playwright. Currently supports posting tweets. version: 1.0.0 user-invocable: true metadata: openclaw: emoji: "🐦" skillKey: "x-twitter-browser" requires: bins: - python3 allowed-tools: Bash(python3:*), browser
x-twitter-browser
Execute browser actions on X using your real browser login state, without the official X API.
Users only need to provide a single cookie header string.
After installing into OpenClaw, the skill lives at:
~/.openclaw/workspace/skills/x-twitter-browser/
Commands below assume you run from the skill root directory:
cd ~/.openclaw/workspace/skills/x-twitter-browser
Use cases
- You want to reuse browser login state instead of the official API
- Running headless on a VM or Linux server
- Building a long-term extensible browser skill for X automation
- You can provide a single
cookie headerstring
Architecture
This skill has two layers:
1. Session layer
Persists the user-provided cookie locally:
scripts/save_cookie_header.pyruntime/cookie-header.txt
2. Action layer
Performs actions using the verified browser session. Currently implemented:
- Post tweet:
scripts/post_tweet.py
Implemented features
- Save user-provided cookie header
- Verify that the session is still logged in
- Post plain-text tweets via the browser session
Dependencies
Minimum requirements:
python3- Python package:
playwright - Playwright Chromium browser
First-time setup:
python3 -m pip install --user playwright
python3 -m playwright install chromium
If Chromium fails due to missing system libraries:
python3 -m playwright install-deps chromium
If you cannot modify the system Python, install playwright in a virtual environment.
Authentication input
Paste the full browser Cookie request header, e.g.:
guest_id=...; auth_token=...; ct0=...; twid=...; ...
Important cookies:
auth_tokenct0twidkdtatt_twitter_sess
Runtime files
Scripts write sensitive runtime files to:
runtime/
Files used:
cookie-header.txt
These files contain account credentials. Do not commit them or share them.
Workflow
1. Save the user-provided cookie
If the user pastes a cookie header, save it to the runtime directory:
mkdir -p runtime
python3 scripts/save_cookie_header.py \
--cookie-header 'guest_id=...; auth_token=...; ct0=...; twid=...'
Or save the cookie to a file first, then import:
cat > runtime/cookie-header.txt <<'EOF'
guest_id=...; auth_token=...; ct0=...; twid=...; ...
EOF
python3 scripts/save_cookie_header.py \
--cookie-file runtime/cookie-header.txt
2. Verify login state
Before any browser action, run:
python3 scripts/post_tweet.py \
--verify-only
Success looks like:
Session looks valid: https://x.com/home
If verification fails, the cookie may be expired. Ask the user to provide a fresh cookie.
3. Post a tweet
After verification succeeds:
python3 scripts/post_tweet.py \
--text "hello"
To read text from a file:
cat > runtime/post.txt <<'EOF'
hello
EOF
python3 scripts/post_tweet.py \
--text-file runtime/post.txt
Rules
--verify-onlysuccess means the session is likely usable- If the page behaves oddly, buttons are disabled, or extra dialogs appear, re-run verification first
- If Chromium fails to start, install Playwright browsers or system deps before blaming the cookie
Operational requirements
- Run
--verify-onlybefore any write operation - Confirm the action and content before executing
- Do not commit cookies or headers to the repo
- Prefer the full cookie header over partial cookies
- Keep all runtime files under
runtime/ - Call
scripts/*.pydirectly
Troubleshooting
Missing dependency: playwright
python3 -m pip install --user playwright
Browser not installed
python3 -m playwright install chromium
Missing system libraries or browser won't start
python3 -m playwright install-deps chromium
Imported session is not authenticated
- Cookie expired
- Incomplete header from user
- Account triggered extra verification
Ask the user to provide a fresh, complete cookie header.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。