mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
改进cookies_to_driver()处理逻辑。域为空的cookie传给driver时自动添加域
This commit is contained in:
parent
54d734089a
commit
cbb9887020
@ -245,9 +245,21 @@ class Drission(object):
|
||||
:param url: 作用域
|
||||
:return: None
|
||||
"""
|
||||
url = extract(url)
|
||||
domain = f'{url.domain}.{url.suffix}'
|
||||
cookies = tuple(x for x in self.session.cookies if domain in x.domain)
|
||||
browser_domain = extract(self.driver.current_url).fqdn
|
||||
ex_url = extract(url)
|
||||
|
||||
if ex_url.fqdn not in browser_domain:
|
||||
self.driver.get(url)
|
||||
|
||||
domain = f'{ex_url.domain}.{ex_url.suffix}'
|
||||
|
||||
cookies = []
|
||||
for cookie in self.session.cookies:
|
||||
if cookie.domain == '':
|
||||
cookie.domain = domain
|
||||
|
||||
if domain in cookie.domain:
|
||||
cookies.append(cookie)
|
||||
|
||||
self.set_cookies(cookies, set_driver=True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user