forked from jessfin/nssign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (30 loc) · 1.32 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from playwright.sync_api import sync_playwright
import requests
import json
import time
accounts = [
{'username': 'username1', 'password': 'password1'},
{'username': 'username2', 'password': 'password2'},
{'username': 'username3', 'password': 'password3'} #参照此示例可以继续添加需要签到的账号
]
with sync_playwright() as p:
for account in accounts:
browser = p.firefox.launch()
page = browser.new_page()
page.goto('https://www.nodeseek.com/signIn.html')
page.fill('#stacked-email', account['username'])
page.fill('#stacked-password', account['password'])
page.click('//button[@type="submit"]')
time.sleep(60)
cookies = page.context.cookies()
cookie_str = "; ".join([f"{cookie['name']}={cookie['value']}" for cookie in cookies])
url = "https://www.nodeseek.com/api/attendance?random=true"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0",
"Cookie": cookie_str
}
response = requests.post(url, headers=headers)
data = json.loads(response.text)
print(f"用户名: {account['username']}")
print(data["message"])
browser.close()