mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
完善浏览器cookies设置
This commit is contained in:
parent
1c5c38b651
commit
91624d3458
@ -158,8 +158,9 @@ def test_connect(ip, port):
|
||||
sleep(.2)
|
||||
|
||||
if ip in ('127.0.0.1', 'localhost'):
|
||||
raise BrowserConnectError(f'\n连接浏览器失败,可能原因:\n1、{port}端口不是Chromium内核浏览器\n'
|
||||
f'2、该浏览器未允许控制\n3、和已打开的浏览器冲突,请关闭')
|
||||
raise BrowserConnectError(f'\n连接浏览器失败,可能原因:\n1、浏览器未启动\n2、{port}端口不是Chromium内核浏览器\n'
|
||||
f'3、该浏览器未允许控制\n4、和已打开的浏览器冲突\n'
|
||||
f'请尝试用ChromiumOptions指定别的端口和指定浏览器路径')
|
||||
raise BrowserConnectError(f'{ip}:{port}浏览器无法链接。')
|
||||
|
||||
|
||||
|
@ -268,14 +268,14 @@ def set_browser_cookies(page, cookies):
|
||||
d_list = ex_url.subdomain.split('.')
|
||||
d_list.append(f'{ex_url.domain}.{ex_url.suffix}' if ex_url.suffix else ex_url.domain)
|
||||
|
||||
for i in range(len(d_list)):
|
||||
d = f'.{".".join(d_list[i:])}'
|
||||
cookie['domain'] = d
|
||||
page.run_cdp_loaded('Network.setCookie', **cookie)
|
||||
if is_cookie_in_driver(page, cookie):
|
||||
break
|
||||
tmp = [d_list[0]]
|
||||
if len(d_list) > 1:
|
||||
for i in d_list[1:]:
|
||||
tmp.append('.')
|
||||
tmp.append(i)
|
||||
|
||||
d = f'{".".join(d_list[i:])}'
|
||||
for i in range(len(tmp)):
|
||||
d = ''.join(tmp[i:])
|
||||
cookie['domain'] = d
|
||||
page.run_cdp_loaded('Network.setCookie', **cookie)
|
||||
if is_cookie_in_driver(page, cookie):
|
||||
|
Loading…
x
Reference in New Issue
Block a user