MCPcopy
hub / github.com/TechXueXi/TechXueXi / set_cookies

Method set_cookies

SourcePackages/pdlearn/mydriver.py:289–309  ·  view source on GitHub ↗
(self, cookies)

Source from the content-addressed store, hash-verified

287 return cookies
288
289 def set_cookies(self, cookies):
290 try:
291 # 解决Chrome 90版本无法运行的问题[https://github.com/TechXueXi/TechXueXi/issues/78]
292 for cookie in cookies:
293 cookie_domain = cookie["domain"]
294 # fix cookie domain `.pc.xuexi.cn` caused refresh fail
295 if cookie_domain.endswith("pc.xuexi.cn"):
296 self.driver.get("https://pc.xuexi.cn/")
297 elif cookie_domain.endswith(".xuexi.cn"):
298 self.driver.get("https://www.xuexi.cn/")
299 else:
300 print(f"unknown cookie domain {cookie_domain}, skip it")
301 continue
302
303 # print(f'current cookie: {cookie}')
304 # for expiry error (maybe old version compatibility) add by Sean 20210706
305 if 'expiry' in cookie:
306 cookie['expiry'] = int(cookie['expiry'])
307 self.driver.add_cookie(cookie)
308 except exceptions.InvalidCookieDomainException as e:
309 print(e.__str__)
310
311 def title_is(self, title):
312 return self.driver.title == title

Callers 7

refresh_all_cookiesFunction · 0.95
articleFunction · 0.95
videoFunction · 0.95
answer_questionFunction · 0.95
dailyFunction · 0.95
weeklyFunction · 0.95
zhuanxiangFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected