-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathchina_news.py
39 lines (32 loc) · 884 Bytes
/
china_news.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @Time : 2020/11/16 12:19
# @Author : Oscar
import hashlib
import time
dt_13 = round(time.time() * 1000)
def r_params():
print("当前时间戳:{0}".format(dt_13))
results = []
payload = {
"appKey": "CNSAPP",
"appSecret": "NJAGTABQ",
"dtp": "7",
"isWap": "yes",
"language": "chs",
"timestrap": "{0}".format(dt_13),
"version_chinanews": "6.7.8",
}
for key, value in payload.items():
results.append(value)
result = ''.join(results)
return result
def token_md5(params):
md = hashlib.md5()
md.update(params.encode('utf-8'))
return md.hexdigest()
if __name__ == '__main__':
r = r_params()
print("参数拼接结果:{0}".format(r))
access_token = token_md5(r)
print("token 加密结果:{0}".format(access_token))