Commit ea8a30ef1eaf079070f2e9ddf20009f47683cf60
1 parent
1df65361
更新mysession文件
Showing
1 changed file
with
15 additions
and
4 deletions
commons/MySession.py
... | ... | @@ -37,9 +37,11 @@ class mysession(): |
37 | 37 | self.keep_alive = False |
38 | 38 | self.ssl_verify = False |
39 | 39 | self.proxies = None |
40 | +# self.proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'} | |
40 | 41 | self.allow_redirects = False |
42 | + self.firmid={"group":"1","hd":"2","cd":"3","qqhe":"4","mdj":"5","gy":"6","cc":"7","sg":"8","sy":"9"} | |
43 | + | |
41 | 44 | |
42 | - # self.proxies={'http': 'http://localhost:8888', 'https': 'http://localhost:8888'} | |
43 | 45 | def cliLogin(self): |
44 | 46 | self.webHeaders, self.clientHeaders, self.userInfo = cliSession().loginUser() |
45 | 47 | |
... | ... | @@ -52,10 +54,17 @@ class mysession(): |
52 | 54 | # requests.session()会话保持,比如使用session成功的登录了某个网站, |
53 | 55 | # 则在再次使用该session对象求求该网站的其他网页都会默认使用该session之前使用的cookie等参数 |
54 | 56 | self.se = requests.session() |
57 | + #更新cookie加入UAP_firmId | |
58 | + firm=account.split("_")[0] | |
59 | + co = requests.cookies.RequestsCookieJar() | |
60 | + co.set("UAP_firmId", self.firmid[firm]) | |
61 | + self.se.cookies.update(co) | |
55 | 62 | # 使用session对象的方法POST/GET等 |
56 | 63 | re = self.se.post(url=self.url, headers=self.header, data=self.body, proxies=self.proxies, **kwargs) |
64 | + #获取关键信息供其他接口header使用 | |
65 | + self.UAP_accessToken=self.se.cookies["UAP_accessToken"] | |
66 | + self.UAP_refreshToken=self.se.cookies["UAP_refreshToken"] | |
57 | 67 | # 返回session对象,供其他接口使用 |
58 | - # print(self.se.cookies) | |
59 | 68 | return self.se |
60 | 69 | |
61 | 70 | def close_session(self): |
... | ... | @@ -211,5 +220,7 @@ class mysession(): |
211 | 220 | my = mysession() |
212 | 221 | my.set_mark() |
213 | 222 | my.cliLogin() |
214 | -s1 = my.get_session("user01") | |
215 | -s2 = my.get_session("user02") | |
216 | 223 | \ No newline at end of file |
224 | +s1 = my.get_session("sg_user01") | |
225 | +s2 = my.get_session("sg_user02") | |
226 | +# sg1=my.get_session("sg_user01") | |
227 | +# sy1=my.get_session("sy_user01") | ... | ... |