重构为 HTTP SSO 扫码方案并引入 Vue3 前端

移除 Playwright 浏览器自动化,改用 passport/SSO HTTP 接口获取二维码与轮询登录;后端模块化拆分,前端替换为 Vue3 SPA。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
travel
2026-06-25 10:47:55 +08:00
parent 853dacf528
commit 9e0644095f
33 changed files with 4792 additions and 1640 deletions
+45
View File
@@ -0,0 +1,45 @@
import requests
import time
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
def try_flow(referer, service, aid, next_url=None):
headers = {
"User-Agent": UA,
"Referer": referer,
"Accept": "application/json, text/plain, */*",
"Origin": referer.rstrip("/"),
}
s = requests.Session()
s.post(
"https://ttwid.bytedance.com/ttwid/union/register/",
json={
"region": "cn",
"aid": 1768,
"needFid": False,
"service": "www.douyin.com",
"migrate_info": {"ticket": "", "source": "web"},
"cbUrlProtocol": "https",
"union": True,
},
headers=headers,
timeout=15,
)
s.get(referer, headers=headers, timeout=15)
ts = int(time.time() * 1000)
params = {"aid": str(aid), "service": service, "is_vcd": "1", "t": ts}
if next_url:
params["next"] = next_url
r = s.get("https://sso.douyin.com/get_qrcode/", params=params, headers=headers, timeout=15)
print("===", referer, aid, r.status_code, r.headers.get("content-type"))
if "json" in (r.headers.get("content-type") or ""):
print(r.text[:500])
else:
print(r.text[:100])
for ref, svc, aid, nxt in [
("https://creator.douyin.com/", "https://creator.douyin.com", 2906, "https://creator.douyin.com"),
("https://www.douyin.com/", "https://www.douyin.com", 6383, None),
("https://www.douyin.com/", "https://www.douyin.com", 1128, "https://www.douyin.com"),
]:
try_flow(ref, svc, aid, nxt)