diff --git a/DrissionPage/base.py b/DrissionPage/base.py index 052edc7..cd3ae8d 100644 --- a/DrissionPage/base.py +++ b/DrissionPage/base.py @@ -62,10 +62,10 @@ class BaseElement(BaseParser): pass def prev(self, index=1): - return None # ShadowRootElement直接继承 + return None # ChromiumShadowRoot直接继承 def prevs(self) -> None: - return None # ShadowRootElement直接继承 + return None # ChromiumShadowRoot直接继承 def next(self, index=1): pass diff --git a/DrissionPage/commons/web.py b/DrissionPage/commons/web.py index 6d14b91..2e54997 100644 --- a/DrissionPage/commons/web.py +++ b/DrissionPage/commons/web.py @@ -255,14 +255,21 @@ def set_browser_cookies(page, cookies): cookie['expires'] = int(cookie['expires']) if cookie['value'] is None: cookie['value'] = '' + if cookie['name'].startswith('__Secure-'): + cookie['secure'] = True - if cookie.get('domain', None): - try: - page.run_cdp_loaded('Network.setCookie', **cookie) - if is_cookie_in_driver(page, cookie): - continue - except Exception: - pass + if cookie['name'].startswith('__Host-'): + cookie['path'] = '/' + cookie['secure'] = True + + else: + if cookie.get('domain', None): + try: + page.run_cdp_loaded('Network.setCookie', **cookie) + if is_cookie_in_driver(page, cookie): + continue + except Exception: + pass ex_url = extract(page._browser_url) d_list = ex_url.subdomain.split('.')