mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-05 05:28:43 +08:00
完善_try_to_connect()逻辑
This commit is contained in:
parent
f4e80fdd92
commit
94ab5975a9
@ -101,20 +101,17 @@ class DriverPage(object):
|
||||
:return: 是否成功
|
||||
"""
|
||||
err = None
|
||||
|
||||
def go() -> bool:
|
||||
nonlocal err
|
||||
try:
|
||||
self.driver.get(to_url)
|
||||
return True
|
||||
except Exception as e:
|
||||
err = e
|
||||
return False
|
||||
|
||||
is_ok = False
|
||||
|
||||
for _ in range(times + 1):
|
||||
is_ok = self.check_page() if go() else False
|
||||
try:
|
||||
self.driver.get(to_url)
|
||||
go_ok = True
|
||||
except Exception as e:
|
||||
err = e
|
||||
go_ok = False
|
||||
|
||||
is_ok = self.check_page() if go_ok else False
|
||||
|
||||
if is_ok is not False:
|
||||
break
|
||||
|
@ -200,16 +200,13 @@ class SessionPage(object):
|
||||
err = None
|
||||
r = None
|
||||
|
||||
def go() -> Union[Response, None]:
|
||||
nonlocal err
|
||||
for _ in range(times + 1):
|
||||
try:
|
||||
return self._make_response(to_url, mode=mode, show_errmsg=True, **kwargs)[0]
|
||||
r = self._make_response(to_url, mode=mode, show_errmsg=True, **kwargs)[0]
|
||||
except Exception as e:
|
||||
err = e
|
||||
return None
|
||||
r = None
|
||||
|
||||
for _ in range(times + 1):
|
||||
r = go()
|
||||
if r and (r.content != b'' or r.status_code in (403, 404)):
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user