Commit 620b7b5e8506dbe3e39777ceb8c5077feafccd5f
1 parent
a4a74681
新增接口封装脚本
Showing
3 changed files
with
14 additions
and
26 deletions
commons/MySession.py
... | ... | @@ -108,9 +108,9 @@ class mysession(): |
108 | 108 | self.re = self.se.post(url=self.url_client, headers=self.header_client, json=self.body_client, proxies=self.proxies, **kwargs) |
109 | 109 | #组装请求的cookie |
110 | 110 | co = requests.cookies.RequestsCookieJar() |
111 | - co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"])) | |
112 | - co.set("UAP_accessToken", self.re.json()["data"]["accessToken"]) | |
113 | - co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"]) | |
111 | + co.set("UAP_firmId", str(self.re.json()["data"]["user"]["firmId"]),domain=".diligrp.com") | |
112 | + co.set("UAP_accessToken", self.re.json()["data"]["accessToken"],domain=".diligrp.com") | |
113 | + co.set("UAP_refreshToken", self.re.json()["data"]["refreshToken"],domain=".diligrp.com") | |
114 | 114 | self.se.cookies.update(co) |
115 | 115 | # 返回session对象,供其他接口使用 |
116 | 116 | return self.se |
... | ... | @@ -283,8 +283,8 @@ my = mysession() |
283 | 283 | my.set_mark() |
284 | 284 | my.cliLogin() |
285 | 285 | # s1 = my.get_session_client("sy_user01") |
286 | -s1 = my.get_session("sy_user01") | |
287 | -s2 = my.get_session_client("sy_user01") | |
286 | +s1 = my.get_session_client("sy_user01") | |
287 | +s2 = my.get_session_client("sy_user02") | |
288 | 288 | # s3 = my.get_session_client("sy_user03") |
289 | 289 | # s3= my.get_session_client("sg_user02") |
290 | 290 | # sg01=my.get_session_client("sg_user01") | ... | ... |
commons/api/duplicateToken.py
... | ... | @@ -3,9 +3,6 @@ |
3 | 3 | import urllib3 |
4 | 4 | from commons import common as com |
5 | 5 | from commons.MySession import my,s1,s2 |
6 | -import requests | |
7 | -from requests.cookies import remove_cookie_by_name | |
8 | - | |
9 | 6 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
10 | 7 | |
11 | 8 | |
... | ... | @@ -27,19 +24,10 @@ class duplicateToken(): |
27 | 24 | self.header["Host"] = com.get_global_config("global_data", "host", "gateway") |
28 | 25 | |
29 | 26 | def jmsf_duplicate_commit_token(self): |
30 | - re = s2.get(url=self.url, headers=self.header) | |
31 | - print(s2.cookies) | |
32 | - print(s2.cookies.list_domains()) | |
33 | - print(s2.cookies.list_paths()) | |
34 | - # remove_cookie_by_name(s2.cookies,domain="",name="UAP_accessToken") | |
35 | - # remove_cookie_by_name(s2.cookies,domain="",name="UAP_refreshToken") | |
36 | - # print(s2.cookies) | |
27 | + re = s2.get(url=self.url, headers=self.header,proxies=my.myproxies) | |
37 | 28 | return re.json()["data"] |
38 | 29 | |
39 | 30 | |
40 | -# print(s1.headers) | |
41 | -du=duplicateToken() | |
42 | -du.jmsf_duplicate_commit_token() | |
31 | +# du=duplicateToken() | |
32 | +# du.jmsf_duplicate_commit_token() | |
43 | 33 | # print(du.jmsf_duplicate_commit_token()) |
44 | -# print(re.json()) | |
45 | -# print(re.headers) | |
46 | 34 | \ No newline at end of file | ... | ... |
commons/api/weighingServiceSave.py
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | import urllib3 |
4 | 4 | from commons import common as com |
5 | -from commons.MySession import my,s1 | |
5 | +from commons.MySession import my,s1,s2 | |
6 | 6 | from commons.api.duplicateToken import duplicateToken |
7 | 7 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
8 | 8 | du=duplicateToken() |
... | ... | @@ -46,13 +46,13 @@ class weighingServiceSave(): |
46 | 46 | self.url = weighingServiceSave.url.replace("http://test.", com.get_global_config("global_data", "environment", "en")) |
47 | 47 | self.header = weighingServiceSave.header |
48 | 48 | self.header["jmsf_duplicate_commit_token"] = du.jmsf_duplicate_commit_token() |
49 | - self.header["UAP_accessToken"] = s1.cookies["UAP_accessToken"] | |
50 | - self.header["UAP_refreshToken"] = s1.cookies["UAP_refreshToken"] | |
51 | - self.header["UAP_firmId"] = s1.cookies["UAP_firmId"] | |
49 | + self.header["UAP_accessToken"] = s2.cookies["UAP_accessToken"] | |
50 | + self.header["UAP_refreshToken"] = s2.cookies["UAP_refreshToken"] | |
51 | + self.header["UAP_firmId"] = s2.cookies["UAP_firmId"] | |
52 | 52 | self.header["Host"] = com.get_global_config("global_data", "host", "gateway") |
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | 56 | # tt=weighingServiceSave() |
57 | -# re=s1.post(url=tt.url,headers=tt.header,json=tt.body,proxies=my.myproxies) | |
58 | -# print(re.json()) | |
59 | 57 | \ No newline at end of file |
58 | +# re=s2.post(url=tt.url,headers=tt.header,json=tt.body,proxies=my.myproxies) | |
59 | +# # print(re.json()) | |
60 | 60 | \ No newline at end of file | ... | ... |