mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.2.16优化cookies处理逻辑,恢复对tldextract依赖
This commit is contained in:
parent
3832e75a31
commit
518b261365
@ -288,13 +288,17 @@ class WebPageTab(SessionPage, ChromiumTab):
|
|||||||
self.session.headers.update({"User-Agent": selenium_user_agent})
|
self.session.headers.update({"User-Agent": selenium_user_agent})
|
||||||
|
|
||||||
set_session_cookies(self.session, self._get_driver_cookies(as_dict=True))
|
set_session_cookies(self.session, self._get_driver_cookies(as_dict=True))
|
||||||
|
# set_session_cookies(self.session, self._get_driver_cookies(all_domains=True))
|
||||||
|
# set_session_cookies(self.session, self._get_driver_cookies())
|
||||||
|
|
||||||
def cookies_to_browser(self):
|
def cookies_to_browser(self):
|
||||||
"""把session对象的cookies复制到浏览器"""
|
"""把session对象的cookies复制到浏览器"""
|
||||||
if not self._has_driver:
|
if not self._has_driver:
|
||||||
return
|
return
|
||||||
|
|
||||||
set_browser_cookies(self, super().get_cookies()) # todo: cookies的选择
|
set_browser_cookies(self, super().get_cookies(as_dict=True))
|
||||||
|
# set_browser_cookies(self, super().get_cookies(all_domains=True))
|
||||||
|
# set_browser_cookies(self, super().get_cookies())
|
||||||
|
|
||||||
def get_cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def get_cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies
|
"""返回cookies
|
||||||
|
@ -263,5 +263,5 @@ def set_browser_cookies(page, cookies):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
page.run_cdp_loaded('Network.setCookie', **cookie)
|
page.run_cdp_loaded('Network.setCookie', **cookie)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -362,14 +362,18 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
selenium_user_agent = self.run_cdp('Runtime.evaluate', expression='navigator.userAgent;')['result']['value']
|
selenium_user_agent = self.run_cdp('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})
|
||||||
|
|
||||||
set_session_cookies(self.session, self._get_driver_cookies(as_dict=False)) # 带域名list
|
set_session_cookies(self.session, self._get_driver_cookies(as_dict=True))
|
||||||
|
# set_session_cookies(self.session, self._get_driver_cookies(all_domains=True))
|
||||||
|
# set_session_cookies(self.session, self._get_driver_cookies())
|
||||||
|
|
||||||
def cookies_to_browser(self):
|
def cookies_to_browser(self):
|
||||||
"""把session对象的cookies复制到浏览器"""
|
"""把session对象的cookies复制到浏览器"""
|
||||||
if not self._has_driver:
|
if not self._has_driver:
|
||||||
return
|
return
|
||||||
|
|
||||||
set_browser_cookies(self, super().get_cookies(all_domains=True)) # todo: cookies的选择
|
set_browser_cookies(self, super().get_cookies(as_dict=True))
|
||||||
|
# set_browser_cookies(self, super().get_cookies(all_domains=True))
|
||||||
|
# set_browser_cookies(self, super().get_cookies())
|
||||||
|
|
||||||
def get_cookies(self, as_dict=False, all_domains=False, all_info=False):
|
def get_cookies(self, as_dict=False, all_domains=False, all_info=False):
|
||||||
"""返回cookies
|
"""返回cookies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user