-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest_generate.py
81 lines (66 loc) · 2.03 KB
/
request_generate.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
75
76
77
78
79
80
81
"""
请求格式构造
"""
import time
import hashlib
from rich import print
init_headers = {
"Host": "bmfw.www.gov.cn",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json;charset=UTF-8",
"Content-Length": "235",
"Origin": "http://bmfw.www.gov.cn",
"Connection": "keep-alive",
"DNT": "1",
"Referer": "http://bmfw.www.gov.cn/yqfxdjcx/risk.html",
"Cache-Control": "no-cache",
"x-wif-nonce": "QkjjtiLM2dCratiA",
"x-wif-paasid": "smt-application",
"Pragma": "no-cache"
}
init_data = {
"appId": "NcApplication",
"key": "3C502C97ABDA40D0A60FBEE50FAAD1DA",
"nonceHeader": "123456789abcdefg",
"paasHeader": "zdww",
}
def getTimestamp() -> str:
"""
获取当前时间的时间戳格式
"""
nanoSeconds = time.time_ns()
return str(round(nanoSeconds / 1e9))
def get_request_parameters():
currentTime = getTimestamp()
# 请求头
init_headers["x-wif-signature"] = (
hashlib.sha256(
(
currentTime
+ "fTN2pfuisxTavbTuYVSsNJHetwq5bJvCQkjjtiLM2dCratiA"
+ currentTime
).encode("utf-8")
)
.hexdigest()
.upper()
)
init_headers["x-wif-timestamp"] = currentTime
# 请求数据
init_data["signatureHeader"] = (
hashlib.sha256(
(
currentTime
+ "23y0ufFl5YxIyGrI8hWRUZmKkvtSjLQA"
+ "123456789abcdefg"
+ currentTime
).encode("utf-8")
)
.hexdigest()
.upper()
)
init_data["timestampHeader"] = currentTime
print(":package:[blue]请求构造完毕 Ready to go")
return init_headers, init_data