mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
3.2.3cookies_to_driver()改名为cookies_to_browser()
This commit is contained in:
parent
3612fe13e7
commit
6e5c16fee6
@ -64,7 +64,10 @@ class ChromiumBase(BasePage):
|
|||||||
self._chromium_init()
|
self._chromium_init()
|
||||||
if not tab_id:
|
if not tab_id:
|
||||||
json = self._control_session.get(f'http://{self.address}/json').json()
|
json = self._control_session.get(f'http://{self.address}/json').json()
|
||||||
tab_id = [i['id'] for i in json if i['type'] == 'page'][0]
|
tab_id = [i['id'] for i in json if i['type'] == 'page']
|
||||||
|
if not tab_id:
|
||||||
|
raise ConnectionError('连接浏览器失败。')
|
||||||
|
tab_id = tab_id[0]
|
||||||
self._driver_init(tab_id)
|
self._driver_init(tab_id)
|
||||||
self._get_document()
|
self._get_document()
|
||||||
self._first_run = False
|
self._first_run = False
|
||||||
|
@ -81,7 +81,10 @@ class ChromiumPage(ChromiumBase):
|
|||||||
self.process = connect_browser(self._driver_options)[1]
|
self.process = connect_browser(self._driver_options)[1]
|
||||||
if not tab_id:
|
if not tab_id:
|
||||||
json = self._control_session.get(f'http://{self.address}/json').json()
|
json = self._control_session.get(f'http://{self.address}/json').json()
|
||||||
tab_id = [i['id'] for i in json if i['type'] == 'page'][0]
|
tab_id = [i['id'] for i in json if i['type'] == 'page']
|
||||||
|
if not tab_id:
|
||||||
|
raise ConnectionError('连接浏览器失败。')
|
||||||
|
tab_id = tab_id[0]
|
||||||
|
|
||||||
self._driver_init(tab_id)
|
self._driver_init(tab_id)
|
||||||
self._get_document()
|
self._get_document()
|
||||||
@ -398,7 +401,7 @@ class ChromiumTabRect(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def browser_location(self):
|
def browser_location(self):
|
||||||
"""返回浏览器在屏幕上的坐标"""
|
"""返回浏览器在屏幕上的坐标,左上角为(0, 0)"""
|
||||||
r = self._get_browser_rect()
|
r = self._get_browser_rect()
|
||||||
if r['windowState'] in ('maximized', 'fullscreen'):
|
if r['windowState'] in ('maximized', 'fullscreen'):
|
||||||
return 0, 0
|
return 0, 0
|
||||||
|
@ -36,7 +36,7 @@ def configs_to_here(save_name=None):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
om = OptionsManager('default')
|
om = OptionsManager('default')
|
||||||
save_name = str(save_name) if save_name is not None else 'dp_configs.ini'
|
save_name = f'{save_name}.ini' if save_name is not None else 'dp_configs.ini'
|
||||||
om.save(save_name)
|
om.save(save_name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
|
|
||||||
if self._session_url:
|
if self._session_url:
|
||||||
if copy_cookies:
|
if copy_cookies:
|
||||||
self.cookies_to_driver()
|
self.cookies_to_browser()
|
||||||
|
|
||||||
if go:
|
if go:
|
||||||
self.get(self._session_url)
|
self.get(self._session_url)
|
||||||
@ -356,8 +356,8 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
|
|
||||||
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)
|
||||||
|
|
||||||
def cookies_to_driver(self):
|
def cookies_to_browser(self):
|
||||||
"""把session对象的cookies复制到driver对象"""
|
"""把session对象的cookies复制到浏览器"""
|
||||||
ex_url = extract(self._session_url)
|
ex_url = extract(self._session_url)
|
||||||
domain = f'{ex_url.domain}.{ex_url.suffix}'
|
domain = f'{ex_url.domain}.{ex_url.suffix}'
|
||||||
cookies = []
|
cookies = []
|
||||||
|
@ -118,7 +118,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
|
|
||||||
def cookies_to_session(self, copy_user_agent: bool = True) -> None: ...
|
def cookies_to_session(self, copy_user_agent: bool = True) -> None: ...
|
||||||
|
|
||||||
def cookies_to_driver(self) -> None: ...
|
def cookies_to_browser(self) -> None: ...
|
||||||
|
|
||||||
def get_cookies(self, as_dict: bool = False, all_domains: bool = False) -> Union[dict, list]: ...
|
def get_cookies(self, as_dict: bool = False, all_domains: bool = False) -> Union[dict, list]: ...
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user