Skip to content

feat: 添加 LeetCode CN Cookie 自动更新工具#177

Merged
QuBenhao merged 7 commits intomasterfrom
feat/cookie-auto-updater
Mar 14, 2026
Merged

feat: 添加 LeetCode CN Cookie 自动更新工具#177
QuBenhao merged 7 commits intomasterfrom
feat/cookie-auto-updater

Conversation

@QuBenhao
Copy link
Owner

功能说明

解决 LeetCode CN Cookie 30天过期需要手动更新的问题。

使用方法

1. 安装依赖

pip install browser-cookie3 PyGithub

2. 创建 GitHub Token

需要 repo 权限:https://github.com/settings/tokens/new?scopes=repo

3. 运行脚本

export GITHUB_TOKEN="ghp_your_token"
python tools/leetcode_cookie_updater.py

4. 设置定时任务(每周自动更新)

# crontab -e
0 9 * * 1 GITHUB_TOKEN="ghp_your_token" python /path/to/LeetCode/tools/leetcode_cookie_updater.py

工作原理

本地浏览器(已登录)
    ↓
browser-cookie3 读取 Cookie
    ↓
PyGithub 更新 GitHub Secrets
    ↓
GitHub Actions 使用新 Cookie

为什么在本地运行?

  • 需要从浏览器读取登录状态
  • 服务器没有浏览器和登录信息
  • Cookie 约30天过期,建议每周更新一次

注意事项

  • 需要在本地电脑运行(有浏览器的机器)
  • 需要已经在浏览器中登录过 leetcode.cn
  • GitHub Token 需要妥善保管

@QuBenhao QuBenhao merged commit 8fe706e into master Mar 14, 2026
@QuBenhao QuBenhao deleted the feat/cookie-auto-updater branch March 14, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant