ワンクリックで
auto-cookie-capture
自动获取网站/App Cookie 的技术方案:Playwright 模拟登录、requests 直接登录、mitmproxy 抓包。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
自动获取网站/App Cookie 的技术方案:Playwright 模拟登录、requests 直接登录、mitmproxy 抓包。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Delegate coding to OpenAI Codex CLI (features, PRs).
Configure, extend, or contribute to Hermes Agent.
Manage multiple remote servers from Hermes via SSH — deploy services, configure firewalls, transfer files, run commands across servers
Clone/create/fork repos; manage remotes, releases.
Parallel data collection from web sources, APIs, and documentation sites
Deploy static sites to GitHub Pages via API — create repo, push, enable Pages, all from CLI
| name | auto-cookie-capture |
| description | 自动获取网站/App Cookie 的技术方案:Playwright 模拟登录、requests 直接登录、mitmproxy 抓包。 |
| version | 1.0.0 |
| author | Hermes |
| metadata | {"hermes":{"tags":["automation","cookie","login","scraping"]}} |
原理:启动真实浏览器,自动填写账号密码,获取登录后的 Cookie。
import json
import asyncio
from playwright.async_api import async_playwright
async def get_fanqie_cookies():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
context = await browser.new_context()
page = await context.new_page()
# 访问登录页
await page.goto('https://fanqienovel.com')
await page.click('text=登录')
# 手机号登录
await page.fill('input[placeholder="请输入手机号"]', 'YOUR_PHONE')
await page.fill('input[placeholder="请输入验证码"]', 'YOUR_CODE')
# 注意:验证码需要手动处理或接打码平台
await page.click('button:has-text("登录")')
# 等待登录完成
await page.wait_for_url('**/library**', timeout=10000)
# 获取所有 Cookie
cookies = await context.cookies()
# 保存到文件
with open('/home/admin/.hermes/secrets/fanqie_cookies.json', 'w') as f:
json.dump(cookies, f, indent=2)
await browser.close()
return cookies
# 运行
asyncio.run(get_fanqie_cookies())
def cookies_to_header(cookies):
return '; '.join(f"{c['name']}={c['value']}" for c in cookies)
cookie_str = cookies_to_header(cookies)
原理:直接调用登录 API,获取返回的 Token/Cookie。
import requests
def login_fanqie(phone, code):
session = requests.Session()
# 登录接口
resp = session.post('https://fanqienovel.com/api/user/login', json={
'phone': phone,
'code': code,
'type': 'phone'
})
if resp.status_code == 200:
cookies = session.cookies.get_dict()
return cookies
return None
前提:手机和电脑在同一局域网。
pip install mitmproxy
mitmdump --set block_global=false -p 8888 -w capture.flow
mitm.it 安装证书from mitmproxy.io import FlowReader
with open('capture.flow', 'rb') as f:
for flow in FlowReader(f).stream():
if 'api' in flow.request.pretty_url:
print(flow.request.pretty_url)
print(flow.request.headers.get('cookie'))
原理:通过 ADB 连接手机,用 adb shell 直接读取 App 数据。
# 连接手机(USB调试)
adb devices
# 查看 App 数据
adb shell run-as com.kurogame.xxx cat /data/data/com.kurogame.xxx/shared_prefs/*.xml
# 或用 logcat 抓取网络请求
adb logcat | grep -i "cookie\|token\|authorization"
所有 Cookie 保存到 ~/.hermes/secrets/ 目录:
~/.hermes/secrets/
├── fanqie_cookies.json
├── kurogame_token.json
└── jieqicookie.json
告诉我"获取番茄 Cookie"或"抓库街区 Token",我会: