3.0.19修复cookies_to_session()问题

This commit is contained in:
g1879 2022-11-29 01:12:23 +08:00
parent 1d4b6290ac
commit 656a1a9b20
2 changed files with 3 additions and 3 deletions

View File

@ -255,13 +255,13 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
if url.startswith('http'): if url.startswith('http'):
self.get(url) 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 """把driver对象的cookies复制到session对象 \n
:param copy_user_agent: 是否复制ua信息 :param copy_user_agent: 是否复制ua信息
:return: None :return: None
""" """
if copy_user_agent: 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.session.headers.update({"User-Agent": selenium_user_agent})
self.set_cookies(self._get_driver_cookies(as_dict=True), set_session=True) self.set_cookies(self._get_driver_cookies(as_dict=True), set_session=True)

View File

@ -6,7 +6,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
setup( setup(
name="DrissionPage", name="DrissionPage",
version="3.0.16", version="3.0.19",
author="g1879", author="g1879",
author_email="g1879@qq.com", author_email="g1879@qq.com",
description="A module that integrates selenium and requests session, encapsulates common page operations.", description="A module that integrates selenium and requests session, encapsulates common page operations.",