使用 DrissionPage 自动化浏览器操作,给指定的 GitHub 项目点 Star。
- 自动给指定的 GitHub 仓库点 Star
- 支持接管已打开的 Chrome 浏览器
- 自动检测仓库是否已被 Star
- 支持登录状态检测
pip install -r requirements.txtWindows:
chrome.exe --remote-debugging-port=9222macOS:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222Linux:
google-chrome --remote-debugging-port=9222修改 main() 函数中的 repo_url 变量,然后运行:
python github_star.pyfrom github_star import star_repo_with_existing_browser
# 给单个仓库点 Star
result = star_repo_with_existing_browser('https://github.com/owner/repo')
print(result)from github_star import star_repo_with_existing_browser
repos = [
'https://github.com/anthropics/anthropic-cookbook',
'https://github.com/anthropics/courses',
]
for repo in repos:
result = star_repo_with_existing_browser(repo)
print(f'{repo}: {result}')| 返回值 | 说明 |
|---|---|
already_starred |
仓库已经是 Star 状态,无需操作 |
star_success |
成功给仓库点 Star |
star_failed |
点击 Star 按钮后验证失败 |
button_not_found |
未找到 Star 按钮(可能页面未加载完成) |
not_logged_in |
用户未登录 GitHub |
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
repo_url |
str | 必填 | GitHub 仓库的 URL |
port |
int | 9222 | Chrome 浏览器调试端口 |
- 请确保 Chrome 浏览器以调试模式启动
- 请确保已在浏览器中登录 GitHub 账号
- 默认调试端口为 9222,可通过
port参数修改 - 脚本会等待页面加载,请保持网络畅通
MIT License