Files
OSU-Public-Wi-Fi-Login/README.md

61 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OSU Public Wi-Fi Auto Login
自动登录 OSUOhio State University公共 Wi-Fi 的脚本。通过 Selenium 驱动 Edge 浏览器,自动完成 Captive Portal 的条款确认和登录操作。
## 工作原理
1. 检测当前网络是否已连接(通过 HTTP 204 / connecttest 验证)
2. 若未连接,使用 headless Edge 浏览器访问 Captive Portal 触发 URL自动尝试多个备选地址
3. 自动勾选 "I accept the terms of use" 并点击 "Log In"
4. 登录后轮询验证网络是否真正连通,失败则自动重试(最多 3 次)
## 环境要求
- Python >= 3.14
- Microsoft Edge 浏览器
- [uv](https://docs.astral.sh/uv/) 包管理器
## 安装
```bash
uv sync
```
## 使用
```bash
uv run main.py
```
### 可选参数
| 参数 | 说明 |
|------|------|
| `--random-mac` | 登录前随机化 Wi-Fi 网卡的 MAC 地址(需要**管理员权限** |
示例:
```bash
# 普通登录
uv run main.py
# 随机 MAC 地址后登录
uv run main.py --random-mac
```
> **注意**`--random-mac` 会通过修改注册表并重启网卡来更改 MAC 地址,需要以管理员身份运行。
## Windows 开机自启
1.`Win + R`,输入 `shell:startup` 打开启动文件夹
2.`run.bat` 的快捷方式放入该文件夹
3. 修改 `run.bat` 中的路径为你的实际项目路径
## 打包为可执行文件
```bash
uv run pyinstaller --onefile main.py
```
生成的 `main.exe` 位于 `dist/` 目录下。