mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-12-05 17:18:19 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac5c64319e | ||
|
|
c93834e2f0 | ||
|
|
e3b4200d94 | ||
|
|
0941861f80 |
@@ -1,6 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## v3.1.0 (upcoming)
|
||||
## v3.0.2 (2023/01/08)
|
||||
|
||||
* Detect Cloudflare blocked access
|
||||
* Check Chrome / Chromium web browser is installed correctly
|
||||
|
||||
## v3.0.1 (2023/01/06)
|
||||
|
||||
* Kill Chromium processes properly to avoid defunct/zombie processes
|
||||
* Update undetected-chromedriver
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flaresolverr",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"description": "Proxy server to bypass Cloudflare protection",
|
||||
"author": "Diego Heras (ngosang / ngosang@hotmail.es)",
|
||||
"license": "MIT"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
from urllib.parse import unquote
|
||||
|
||||
@@ -13,13 +14,19 @@ from dtos import V1RequestBase, V1ResponseBase, ChallengeResolutionT, ChallengeR
|
||||
HealthResponse, STATUS_OK, STATUS_ERROR
|
||||
import utils
|
||||
|
||||
ACCESS_DENIED_TITLES = [
|
||||
# Cloudflare
|
||||
'Access denied',
|
||||
# Cloudflare http://bitturk.net/ Firefox
|
||||
'Attention Required! | Cloudflare'
|
||||
]
|
||||
ACCESS_DENIED_SELECTORS = [
|
||||
# Cloudflare
|
||||
'div.cf-error-title span.cf-code-label span'
|
||||
'div.cf-error-title span.cf-code-label span',
|
||||
# Cloudflare http://bitturk.net/ Firefox
|
||||
'#cf-error-details div.cf-error-overview h1'
|
||||
]
|
||||
CHALLENGE_TITLE = [
|
||||
CHALLENGE_TITLES = [
|
||||
# Cloudflare
|
||||
'Just a moment...',
|
||||
# DDoS-GUARD
|
||||
@@ -36,6 +43,21 @@ SHORT_TIMEOUT = 10
|
||||
|
||||
def test_browser_installation():
|
||||
logging.info("Testing web browser installation...")
|
||||
|
||||
chrome_exe_path = utils.get_chrome_exe_path()
|
||||
if chrome_exe_path is None:
|
||||
logging.error("Chrome / Chromium web browser not installed!")
|
||||
sys.exit(1)
|
||||
else:
|
||||
logging.info("Chrome / Chromium path: " + chrome_exe_path)
|
||||
|
||||
chrome_major_version = utils.get_chrome_major_version()
|
||||
if chrome_major_version == '':
|
||||
logging.error("Chrome / Chromium version not detected!")
|
||||
sys.exit(1)
|
||||
else:
|
||||
logging.info("Chrome / Chromium major version: " + chrome_major_version)
|
||||
|
||||
user_agent = utils.get_user_agent()
|
||||
logging.info("FlareSolverr User-Agent: " + user_agent)
|
||||
logging.info("Test successful")
|
||||
@@ -174,7 +196,13 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
|
||||
|
||||
# wait for the page
|
||||
html_element = driver.find_element(By.TAG_NAME, "html")
|
||||
page_title = driver.title
|
||||
|
||||
# find access denied titles
|
||||
for title in ACCESS_DENIED_TITLES:
|
||||
if title == page_title:
|
||||
raise Exception('Cloudflare has blocked this request. '
|
||||
'Probably your IP is banned for this site, check in your web browser.')
|
||||
# find access denied selectors
|
||||
for selector in ACCESS_DENIED_SELECTORS:
|
||||
found_elements = driver.find_elements(By.CSS_SELECTOR, selector)
|
||||
@@ -184,8 +212,7 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
|
||||
|
||||
# find challenge by title
|
||||
challenge_found = False
|
||||
page_title = driver.title
|
||||
for title in CHALLENGE_TITLE:
|
||||
for title in CHALLENGE_TITLES:
|
||||
if title == page_title:
|
||||
challenge_found = True
|
||||
logging.info("Challenge detected. Title found: " + title)
|
||||
@@ -202,8 +229,8 @@ def _evil_logic(req: V1RequestBase, driver: WebDriver, method: str) -> Challenge
|
||||
if challenge_found:
|
||||
while True:
|
||||
try:
|
||||
# wait until the title change
|
||||
for title in CHALLENGE_TITLE:
|
||||
# wait until the title changes
|
||||
for title in CHALLENGE_TITLES:
|
||||
logging.debug("Waiting for title: " + title)
|
||||
WebDriverWait(driver, SHORT_TIMEOUT).until_not(title_is(title))
|
||||
|
||||
|
||||
@@ -88,6 +88,10 @@ def get_webdriver() -> WebDriver:
|
||||
return driver
|
||||
|
||||
|
||||
def get_chrome_exe_path() -> str:
|
||||
return uc.find_chrome_executable()
|
||||
|
||||
|
||||
def get_chrome_major_version() -> str:
|
||||
global CHROME_MAJOR_VERSION
|
||||
if CHROME_MAJOR_VERSION is not None:
|
||||
@@ -112,7 +116,6 @@ def get_chrome_major_version() -> str:
|
||||
process.close()
|
||||
|
||||
CHROME_MAJOR_VERSION = complete_version.split('.')[0].split(' ')[-1]
|
||||
logging.info(f"Chrome major version: {CHROME_MAJOR_VERSION}")
|
||||
return CHROME_MAJOR_VERSION
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user