mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-07 12:05:37 +00:00
Fix for new Cloudflare detection. Thanks @cedric-bour for #845
This commit is contained in:
parent
5ba9ef03f3
commit
22ed3d324b
@ -251,7 +251,7 @@ def _resolve_challenge(req: V1RequestBase, method: str) -> ChallengeResolutionT:
|
|||||||
|
|
||||||
def click_verify(driver: WebDriver):
|
def click_verify(driver: WebDriver):
|
||||||
try:
|
try:
|
||||||
logging.debug("Try to find the Cloudflare verify checkbox")
|
logging.debug("Try to find the Cloudflare verify checkbox...")
|
||||||
iframe = driver.find_element(By.XPATH, "//iframe[@title='Widget containing a Cloudflare security challenge']")
|
iframe = driver.find_element(By.XPATH, "//iframe[@title='Widget containing a Cloudflare security challenge']")
|
||||||
driver.switch_to.frame(iframe)
|
driver.switch_to.frame(iframe)
|
||||||
checkbox = driver.find_element(
|
checkbox = driver.find_element(
|
||||||
@ -263,14 +263,14 @@ def click_verify(driver: WebDriver):
|
|||||||
actions.move_to_element_with_offset(checkbox, 5, 7)
|
actions.move_to_element_with_offset(checkbox, 5, 7)
|
||||||
actions.click(checkbox)
|
actions.click(checkbox)
|
||||||
actions.perform()
|
actions.perform()
|
||||||
logging.debug("Cloudflare verify checkbox found and clicked")
|
logging.debug("Cloudflare verify checkbox found and clicked!")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logging.debug("Cloudflare verify checkbox not found on the page")
|
logging.debug("Cloudflare verify checkbox not found on the page. Error: " + str(e))
|
||||||
finally:
|
finally:
|
||||||
driver.switch_to.default_content()
|
driver.switch_to.default_content()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.debug("Try to find the Cloudflare 'Verify you are human' button")
|
logging.debug("Try to find the Cloudflare 'Verify you are human' button...")
|
||||||
button = driver.find_element(
|
button = driver.find_element(
|
||||||
by=By.XPATH,
|
by=By.XPATH,
|
||||||
value="//input[@type='button' and @value='Verify you are human']",
|
value="//input[@type='button' and @value='Verify you are human']",
|
||||||
@ -280,10 +280,9 @@ def click_verify(driver: WebDriver):
|
|||||||
actions.move_to_element_with_offset(button, 5, 7)
|
actions.move_to_element_with_offset(button, 5, 7)
|
||||||
actions.click(button)
|
actions.click(button)
|
||||||
actions.perform()
|
actions.perform()
|
||||||
logging.debug("The Cloudflare 'Verify you are human' button found and clicked")
|
logging.debug("The Cloudflare 'Verify you are human' button found and clicked!")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.debug("The Cloudflare 'Verify you are human' button not found on the page")
|
logging.debug("The Cloudflare 'Verify you are human' button not found on the page. Error: " + str(e))
|
||||||
# print(e)
|
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
@ -298,7 +297,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)
|
with driver:
|
||||||
|
driver.get(req.url)
|
||||||
|
|
||||||
# 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:
|
||||||
@ -310,7 +310,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)
|
with driver:
|
||||||
|
driver.get(req.url)
|
||||||
|
|
||||||
# wait for the page
|
# wait for the page
|
||||||
if utils.get_config_log_html():
|
if utils.get_config_log_html():
|
||||||
@ -429,4 +430,5 @@ def _post_request(req: V1RequestBase, driver: WebDriver):
|
|||||||
<script>document.getElementById('hackForm').submit();</script>
|
<script>document.getElementById('hackForm').submit();</script>
|
||||||
</body>
|
</body>
|
||||||
</html>"""
|
</html>"""
|
||||||
driver.get("data:text/html;charset=utf-8," + html_content)
|
with driver:
|
||||||
|
driver.get("data:text/html;charset=utf-8," + html_content)
|
||||||
|
@ -135,9 +135,6 @@ def get_webdriver(proxy: dict = None) -> WebDriver:
|
|||||||
# https://github.com/microsoft/vscode/issues/127800#issuecomment-873342069
|
# https://github.com/microsoft/vscode/issues/127800#issuecomment-873342069
|
||||||
# https://peter.sh/experiments/chromium-command-line-switches/#use-gl
|
# https://peter.sh/experiments/chromium-command-line-switches/#use-gl
|
||||||
options.add_argument('--use-gl=swiftshader')
|
options.add_argument('--use-gl=swiftshader')
|
||||||
# workaround for updated 'verify you are human' check
|
|
||||||
# https://github.com/FlareSolverr/FlareSolverr/issues/811
|
|
||||||
options.add_argument('--auto-open-devtools-for-tabs')
|
|
||||||
|
|
||||||
proxy_extension_dir = None
|
proxy_extension_dir = None
|
||||||
if proxy and all(key in proxy for key in ['url', 'username', 'password']):
|
if proxy and all(key in proxy for key in ['url', 'username', 'password']):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user