-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.py
68 lines (65 loc) · 1.96 KB
/
api.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import requests
import json
from typing import Tuple
import time
def register() -> Tuple[str, str]:
url = "http://127.0.0.1:5000/pc-geetest/register?t=" + str(int(time.time() * 1000))
# url = "https://www.geetest.com/demo/gt/register-slide?t=" + str(int(time.time() * 1000))
res = requests.get(url=url).json()
print(res)
return (res['challenge'], res['gt'])
def get_c_s(challenge: str, gt: str, w: str) -> Tuple[list, str]:
url = "https://api.geetest.com/get.php"
# url = "https://apiv6.geetest.com/get.php"
res = requests.get(url=url, params={
"gt": gt,
"challenge": challenge,
"lang": "zh-cn",
"pt": 0,
"client_type": "web",
"w": w,
}).text
res = json.loads(res.strip('()'))['data']
# print(res)
return (res['c'], res['s'])
def get_type(challenge: str, gt: str, w: str):
url = "http://api.geevisit.com/ajax.php"
res = requests.get(url=url, params={
"gt": gt,
"challenge": challenge,
"w": w
})
def get_new_c_s_challenge_bg_slice(challenge: str, gt: str,) -> Tuple[str, str, str, str, str]:
url = "http://api.geevisit.com/get.php"
res = requests.get(url=url, params={
"gt": gt,
"challenge": challenge,
"is_next": "true",
"offline": "false",
"type": "slide3",
"isPC": "true",
"product": "embed",
"autoReset": "true",
"api_server": "api.geevisit.com",
"protocol": "http://",
"width": "100%",
"callback": "geetest_1715753608245",
}).text
res = res.strip('geetest_1715753608245')
res = res.strip('()')
res = json.loads(res)
print(res)
return (res['c'],res['s'],res['challenge'],
'https://' + res['static_servers'][0] + res['bg'],
'https://' + res['static_servers'][0] + res['slice'])
def ajax(challenge: str, gt: str, w: str):
url = "http://api.geevisit.com/ajax.php"
res = requests.get(url=url, params={
"gt": gt,
"challenge": challenge,
"w": w,
}).text
res = res.strip('()')
res = json.loads(res)
print(res)
return res