From 656a1a9b20058842cba360f6063b0820a88560f1 Mon Sep 17 00:00:00 2001 From: g1879 Date: Tue, 29 Nov 2022 01:12:23 +0800 Subject: [PATCH] =?UTF-8?q?3.0.19=E4=BF=AE=E5=A4=8Dcookies=5Fto=5Fsession(?= =?UTF-8?q?)=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/web_page.py | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DrissionPage/web_page.py b/DrissionPage/web_page.py index e9d2b65..d3b2c3c 100644 --- a/DrissionPage/web_page.py +++ b/DrissionPage/web_page.py @@ -255,13 +255,13 @@ class WebPage(SessionPage, ChromiumPage, BasePage): if url.startswith('http'): self.get(url) - def cookies_to_session(self, copy_user_agent: bool = False) -> None: + def cookies_to_session(self, copy_user_agent: bool = True) -> None: """把driver对象的cookies复制到session对象 \n :param copy_user_agent: 是否复制ua信息 :return: None """ if copy_user_agent: - selenium_user_agent = self.run_script("navigator.userAgent;") + selenium_user_agent = self._tab_obj.Runtime.evaluate(expression='navigator.userAgent;')['result']['value'] self.session.headers.update({"User-Agent": selenium_user_agent}) self.set_cookies(self._get_driver_cookies(as_dict=True), set_session=True) diff --git a/setup.py b/setup.py index ec623c7..4670dc1 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh: setup( name="DrissionPage", - version="3.0.16", + version="3.0.19", author="g1879", author_email="g1879@qq.com", description="A module that integrates selenium and requests session, encapsulates common page operations.",