SetCookie.py
2.92 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import requests
import csv
if __name__ == '__main__':
# host = "http://yq-redpacket-api.vchangyi.com"
# domain = '845C3A9F0A69039F72E7C760BCCE9930' # 企业号“畅移测试T1”
host = "https://k-boxing-rp-eve-api.vchangyi.com"
domain = 'A5AA220A0A69039F1E4115437BDC6FE7'
cookie_list = []
auth = []
data = []
session = []
accessTag = []
res = []
# 读memUid
# filename1 = 'memUid15000.csv'
# filename1 = 'dtdev.csv'
filename1 = 'k-boxing.csv'
filename2 = 'kb-dev_AUTH.csv'
filename3 = 'kb-dev_DATA.csv'
filename4 = 'kb-dev_SESSIONID.csv'
filename5 = 'kb-dev_accessTag.csv'
filename6 = 'resourceauth.csv'
with open(filename1) as f1:
reader = csv.DictReader(f1)
memUidList = [row['memUid'] for row in reader]
f1.close()
# print(len(memUidList))
for i in range(len(memUidList)):
memUid = memUidList[i]
setCookie_url = host + '/red-packets-business/v1/api/b/' + domain + '/login/test/set-cookie?memUid=' + memUid
response = requests.get(setCookie_url)
print(response.json())
cookie = response.cookies
cookie_dict = {}
cookie_str = ''
for item in cookie:
cookie_dict[item.name] = item.value
# cookie_str = cookie_str + item.name + '=' + item.value + ';'
# print(cookie_dict)
# auth[len(auth):len(auth)] = cookie_dict['kb_dev_AUTH'].split()
# data[len(data):len(data)] = cookie_dict['kb_dev_DATA'].split()
# session[len(session):len(session)] = cookie_dict['kb_dev_SESSIONID'].split()
# accessTag[len(accessTag):len(accessTag)] = cookie_dict['kb_dev_accessTag'].split()
# res[len(res):len(res)] = cookie_dict['resourceauth'].split()
auth[len(auth):len(auth)] = cookie_dict['kboxing_AUTH'].split()
data[len(data):len(data)] = cookie_dict['kboxing_DATA'].split()
session[len(session):len(session)] = cookie_dict['kboxing_SESSIONID'].split()
accessTag[len(accessTag):len(accessTag)] = cookie_dict['kboxing_accessTag'].split()
res[len(res):len(res)] = cookie_dict['resourceauth'].split()
with open(filename2, "w", newline='') as f2:
writer = csv.writer(f2)
for row in auth:
writer.writerow([row])
f2.close()
with open(filename3, "w", newline='') as f3:
writer = csv.writer(f3)
for row in data:
writer.writerow([row])
f3.close()
with open(filename4, "w", newline='') as f4:
writer = csv.writer(f4)
for row in session:
writer.writerow([row])
f4.close()
with open(filename5, "w", newline='') as f5:
writer = csv.writer(f5)
for row in accessTag:
writer.writerow([row])
f5.close()
with open(filename6, "w", newline='') as f6:
writer = csv.writer(f6)
for row in res:
writer.writerow([row])
f6.close()