4.0.4.21修复wait.eles_loaded()和设置cookies问题

This commit is contained in:
g1879 2024-03-31 17:32:04 +08:00
parent 5578bf57a5
commit ef577a9131
3 changed files with 12 additions and 5 deletions

View File

@ -14,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions
from ._configs.session_options import SessionOptions
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
__version__ = '4.0.4.20'
__version__ = '4.0.4.21'

View File

@ -207,9 +207,9 @@ def cookies_to_tuple(cookies):
elif isinstance(cookies, str):
c_dict = {}
for attr in cookies.strip().rstrip(';,').split(',' if ',' in cookies else ';'):
for attr in cookies.strip().rstrip(';, ').split(',' if ',' in cookies else ';'):
attr_val = attr.strip().split('=', 1)
c_dict[attr_val[0]] = attr_val[1] if len(attr_val) == 2 else ''
c_dict[attr_val[0]] = attr_val[1] if len(attr_val) == 2 else True
cookies = _dict_cookies_to_tuple(c_dict)
elif isinstance(cookies, dict):
@ -300,6 +300,9 @@ def set_browser_cookies(page, cookies):
except Exception:
pass
if not page._browser_url.startswith('http'):
raise RuntimeError(f'未设置域名请设置cookie的domain参数或先访问一个网站。{cookie}')
ex_url = extract(page._browser_url)
d_list = ex_url.subdomain.split('.')
d_list.append(f'{ex_url.domain}.{ex_url.suffix}' if ex_url.suffix else ex_url.domain)

View File

@ -98,8 +98,12 @@ class BaseWaiter(OriginWaiter):
driver.run('DOM.discardSearchResults', searchId=r['searchId'])
return False
searchId = r['searchId']
ids = driver.run('DOM.getSearchResults', searchId=r['searchId'], fromIndex=0,
toIndex=r['resultCount'] - 1)['nodeIds']
ids = driver.run('DOM.getSearchResults', searchId=searchId, fromIndex=0,
toIndex=r['resultCount'])
if 'error' in ids:
return False
ids = ids['nodeIds']
res = False
for i in ids:
r = driver.run('DOM.describeNode', nodeId=i)