-
Notifications
You must be signed in to change notification settings - Fork 10
/
check.py
74 lines (60 loc) · 2.15 KB
/
check.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
69
70
71
72
73
74
import json
import re
import ddddocr
import requests
import execjs
def check_captcha(session):
with open('./generateCaptchaKey.js', encoding='utf-8') as f:
js = f.read()
# 通过compile命令转成一个js对象
docjs = execjs.compile(js)
# 调用function
res = docjs.call('generateCaptchaKey')
ckey = res['captchaKey']
token = res['token']
data = {
'callback': "callback",
'captchaId': "42sxgHoTPTKbt0uZxPJ7ssOvtXr3ZgZ1",
'type': "slide",
'version': "1.1.14",
'captchaKey': ckey,
'token': token,
'referer': "https://office.chaoxing.com/front/third/apps/seatengine/select",
}
res = session.post('http://captcha.chaoxing.com/captcha/get/verification/image', data=data)
print(res.text)
captcha_data = json.loads(re.search(r'\{.*\}', res.text)[0])
background = requests.get(captcha_data["imageVerificationVo"]["shadeImage"]).content
target = requests.get(captcha_data["imageVerificationVo"]["cutoutImage"]).content
token_new = captcha_data["token"]
det = ddddocr.DdddOcr(det=False, ocr=False)
res_det = det.slide_match(target, background)
print(res_det['target'])
data_check = {
"callback": "callback",
"captchaId": "42sxgHoTPTKbt0uZxPJ7ssOvtXr3ZgZ1",
"type": "slide",
"token": token_new,
"textClickArr": ('[{{\"x\":{x}}}]').format(x=res_det['target'][0]),
"coordinate": "[]",
"runEnv": "10",
"version": "1.1.14"
}
res_check = session.get(
"http://captcha.chaoxing.com/captcha/check/verification/result", params=data_check, headers={
"Referer": "http://office.chaoxing.com/",
})
check_result = json.loads(re.search(r'\{.*\}', res_check.text)[0])
if check_result['result']:
return json.loads(check_result['extraData'])['validate']
else:
print('error')
return res_check.text
def enc(data):
with open('./enc.js', encoding='utf-8') as f:
js = f.read()
# 通过compile命令转成一个js对象
docjs = execjs.compile(js)
# 调用function
res = docjs.call('getMd5Hash', data)
return res