mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-07 12:05:37 +00:00
Co-authored-by: Tadas Gedgaudas <tg@infrahub.io> Co-authored-by: ilike2burnthing <59480337+ilike2burnthing@users.noreply.github.com>
This commit is contained in:
parent
043f18b231
commit
800866d033
@ -287,20 +287,35 @@ def click_verify(driver: WebDriver):
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
|
def get_correct_window(driver: WebDriver) -> WebDriver:
|
||||||
|
if len(driver.window_handles) > 1:
|
||||||
|
for window_handle in driver.window_handles:
|
||||||
|
driver.switch_to.window(window_handle)
|
||||||
|
current_url = driver.current_url
|
||||||
|
if not current_url.startswith("devtools://devtools"):
|
||||||
|
return driver
|
||||||
|
return driver
|
||||||
|
|
||||||
|
|
||||||
|
def access_page(driver: WebDriver, url: str) -> None:
|
||||||
|
driver.get(url)
|
||||||
|
driver.start_session()
|
||||||
|
driver.start_session() # required to bypass Cloudflare
|
||||||
|
|
||||||
|
|
||||||
def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> ChallengeResolutionT:
|
def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> ChallengeResolutionT:
|
||||||
res = ChallengeResolutionT({})
|
res = ChallengeResolutionT({})
|
||||||
res.status = STATUS_OK
|
res.status = STATUS_OK
|
||||||
res.message = ""
|
res.message = ""
|
||||||
|
|
||||||
|
|
||||||
# navigate to the page
|
# navigate to the page
|
||||||
logging.debug(f'Navigating to... {req.url}')
|
logging.debug(f'Navigating to... {req.url}')
|
||||||
driver.get(req.url)
|
|
||||||
driver.start_session() # required to bypass Cloudflare
|
|
||||||
if method == 'POST':
|
if method == 'POST':
|
||||||
_post_request(req, driver)
|
_post_request(req, driver)
|
||||||
else:
|
else:
|
||||||
driver.get(req.url)
|
access_page(driver, req.url)
|
||||||
driver.start_session() # required to bypass Cloudflare
|
driver = get_correct_window(driver)
|
||||||
|
|
||||||
# set cookies if required
|
# set cookies if required
|
||||||
if req.cookies is not None and len(req.cookies) > 0:
|
if req.cookies is not None and len(req.cookies) > 0:
|
||||||
@ -312,8 +327,8 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
|
|||||||
if method == 'POST':
|
if method == 'POST':
|
||||||
_post_request(req, driver)
|
_post_request(req, driver)
|
||||||
else:
|
else:
|
||||||
driver.get(req.url)
|
access_page(driver, req.url)
|
||||||
driver.start_session() # required to bypass Cloudflare
|
driver = get_correct_window(driver)
|
||||||
|
|
||||||
# wait for the page
|
# wait for the page
|
||||||
if utils.get_config_log_html():
|
if utils.get_config_log_html():
|
||||||
@ -433,4 +448,5 @@ def _post_request(req: V1RequestBase, driver: WebDriver):
|
|||||||
</body>
|
</body>
|
||||||
</html>"""
|
</html>"""
|
||||||
driver.get("data:text/html;charset=utf-8," + html_content)
|
driver.get("data:text/html;charset=utf-8," + html_content)
|
||||||
|
driver.start_session()
|
||||||
driver.start_session() # required to bypass Cloudflare
|
driver.start_session() # required to bypass Cloudflare
|
||||||
|
@ -164,6 +164,8 @@ def get_webdriver(proxy: dict = None) -> WebDriver:
|
|||||||
# For normal headless mode:
|
# For normal headless mode:
|
||||||
# options.add_argument('--headless')
|
# options.add_argument('--headless')
|
||||||
|
|
||||||
|
options.add_argument("--auto-open-devtools-for-tabs")
|
||||||
|
|
||||||
# if we are inside the Docker container, we avoid downloading the driver
|
# if we are inside the Docker container, we avoid downloading the driver
|
||||||
driver_exe_path = None
|
driver_exe_path = None
|
||||||
version_main = None
|
version_main = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user