From 1c032a0a5d3f21db7be47e4587ecbee85f58011f Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 2 Jun 2023 21:22:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AEcookies?= =?UTF-8?q?=E6=97=B6=E5=9F=9F=E5=90=8D=E4=B8=8D=E5=AF=B9=E5=BA=94=E6=97=B6?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/commons/web.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DrissionPage/commons/web.py b/DrissionPage/commons/web.py index b9dd703..6d14b91 100644 --- a/DrissionPage/commons/web.py +++ b/DrissionPage/commons/web.py @@ -288,7 +288,13 @@ def is_cookie_in_driver(page, cookie): :param cookie: dict格式cookie :return: bool """ - for c in page.get_cookies(): - if cookie['name'] == c['name'] and cookie['value'] == c['value']: - return True + if 'domain' in cookie: + for c in page.get_cookies(all_domains=True): + if cookie['name'] == c['name'] and cookie['value'] == c['value'] and cookie['domain'] == c.get('domain', + None): + return True + else: + for c in page.get_cookies(all_domains=True): + if cookie['name'] == c['name'] and cookie['value'] == c['value']: + return True return False