Make the challenge wait timeout configurable (#1766)

This commit is contained in:
Aki
2026-08-25 05:17:00 +01:00
committed by GitHub
parent 0f05ed8fc9
commit 716451bc30
4 changed files with 28 additions and 22 deletions
+1
View File
@@ -90,6 +90,7 @@ if __name__ == "__main__":
log_file = os.environ.get('LOG_FILE', None)
log_html = utils.get_config_log_html()
headless = utils.get_config_headless()
browser_wait_timeout = utils.get_config_browser_wait_timeout()
server_host = os.environ.get('HOST', '0.0.0.0')
server_port = int(os.environ.get('PORT', 8191))
+4 -4
View File
@@ -53,7 +53,6 @@ TURNSTILE_SELECTORS = [
"input[name='cf-turnstile-response']"
]
SHORT_TIMEOUT = 1
SESSIONS_STORAGE = SessionsStorage()
@@ -422,6 +421,7 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
logging.info("Challenge detected. Selector found: " + selector)
break
browser_wait_timeout = utils.get_config_browser_wait_timeout()
attempt = 0
if challenge_found:
while True:
@@ -430,12 +430,12 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
# wait until the title changes
for title in CHALLENGE_TITLES:
logging.debug("Waiting for title (attempt " + str(attempt) + "): " + title)
WebDriverWait(driver, SHORT_TIMEOUT).until_not(title_is(title))
WebDriverWait(driver, browser_wait_timeout).until_not(title_is(title))
# then wait until all the selectors disappear
for selector in CHALLENGE_SELECTORS:
logging.debug("Waiting for selector (attempt " + str(attempt) + "): " + selector)
WebDriverWait(driver, SHORT_TIMEOUT).until_not(
WebDriverWait(driver, browser_wait_timeout).until_not(
presence_of_element_located((By.CSS_SELECTOR, selector)))
# all elements not found
@@ -453,7 +453,7 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
logging.debug("Waiting for redirect")
# noinspection PyBroadException
try:
WebDriverWait(driver, SHORT_TIMEOUT).until(staleness_of(html_element))
WebDriverWait(driver, browser_wait_timeout).until(staleness_of(html_element))
except Exception:
logging.debug("Timeout waiting for redirect")
+4
View File
@@ -32,6 +32,10 @@ def get_config_disable_media() -> bool:
return os.environ.get('DISABLE_MEDIA', 'false').lower() == 'true'
def get_config_browser_wait_timeout() -> int:
return int(os.environ.get('BROWSER_WAIT_TIMEOUT', 1))
def get_flaresolverr_version() -> str:
global FLARESOLVERR_VERSION
if FLARESOLVERR_VERSION is not None: