diff --git a/README.md b/README.md index a56f09b..75421ea 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ An alternative to [FlareSolverr](https://github.com/FlareSolverr/FlareSolverr) a | Environment Variable | Default | Description | | -------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `USE_HEADLESS` | `SeleniumBase default` | Use headless chromium. | +| `USE_HEADLESS` | `False` | Use headless chromium. | +| `USE_XVFB` | `SeleniumBase default` | Use activate the special virtual display. | | `PROXY` | None | Proxy to use in format: `protocol://username:password@host:port`. [SOCKS5 with authentication is not supported by Chrome](https://stackoverflow.com/questions/75602916/connection-to-private-proxy-socks5-with-chrome-webrequest-onauthrequired-and), see `compose.yaml` file for a workaround | ## Proxy Recommendation diff --git a/pyproject.toml b/pyproject.toml index b9ac00e..88e5654 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,10 +8,10 @@ version = "0.1.0" description = "API for getting cookies for Cloudflare challenges" readme = "README.md" dependencies = [ - "fastapi[standard]==0.115.14", - "pyautogui==0.9.54", - "pydantic==2.11.7", - "seleniumbase==4.40.0", + "fastapi[standard]==0.115.*", + "pyautogui==0.9.*", + "pydantic==2.11.*", + "seleniumbase==4.*", "uvicorn==0.35.0", ] urls = { repository = "https://github.com/ThePhaseless/Byparr" } diff --git a/src/consts.py b/src/consts.py index d7f7ad0..08e350f 100644 --- a/src/consts.py +++ b/src/consts.py @@ -30,7 +30,7 @@ VERSION = get_version_from_env() or "unknown" USE_XVFB = os.getenv("USE_XVFB") in ["true", "1"] if os.getenv("USE_XVFB") else None USE_HEADLESS = ( - os.getenv("USE_HEADLESS") in ["true", "1"] if os.getenv("USE_HEADLESS") else None + os.getenv("USE_HEADLESS") in ["true", "1"] if os.getenv("USE_HEADLESS") else False ) PROXY = os.getenv("PROXY") @@ -38,6 +38,7 @@ PROXY = os.getenv("PROXY") CHALLENGE_TITLES = [ # Cloudflare "Just a moment...", + "Verifying you are human", # DDoS-GUARD "DDoS-Guard", ] diff --git a/src/utils.py b/src/utils.py index 1816247..33ef24d 100644 --- a/src/utils.py +++ b/src/utils.py @@ -5,7 +5,7 @@ from fastapi import Header, HTTPException from httpx import codes from sbase import SB, BaseCase -from src.consts import LOG_LEVEL, PROXY, USE_HEADLESS +from src.consts import LOG_LEVEL, PROXY, USE_HEADLESS, USE_XVFB logger = logging.getLogger("uvicorn.error") logger.setLevel(LOG_LEVEL) @@ -27,12 +27,19 @@ def get_sb( detail="SOCKS5 proxy with authentication is not supported. Check README for more info.", ) + kwargs = { + "uc": True, + "headless": USE_HEADLESS, + "xvfb": USE_XVFB, + "locale_code": "en", + "ad_block": True, + "proxy": proxy, + } + + logger.info("Creating SeleniumBase instance with parameters: %s", kwargs) + with SB( - uc=True, - headless=USE_HEADLESS, - locale_code="en", - ad_block=True, - proxy=proxy, + **kwargs, ) as sb: yield sb diff --git a/tests/main_test.py b/tests/main_test.py index a76f557..9a1b345 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -11,11 +11,12 @@ client = TestClient(app) test_websites = [ "https://ext.to/", - "https://www.ygg.re/", + # "https://www.ygg.re/", "https://extratorrent.st/", "https://idope.se/", "https://speed.cd/login", - 'https://www.yggtorrent.top/engine/search?do=search&order=desc&sort=publish_date&name="UNESCAPED"+"DOUBLEQUOTES"&category=2145' + 'https://www.yggtorrent.top/engine/search?do=search&order=desc&sort=publish_date&name="UNESCAPED"+"DOUBLEQUOTES"&category=2145', + "https://freedium.cfd/https://codingplainenglish.medium.com/docker-is-dead-and-its-about-time-b457d14b0a72" ] diff --git a/uv.lock b/uv.lock index 6b59179..64b50f5 100644 --- a/uv.lock +++ b/uv.lock @@ -87,10 +87,10 @@ test = [ [package.metadata] requires-dist = [ - { name = "fastapi", extras = ["standard"], specifier = "==0.115.14" }, - { name = "pyautogui", specifier = "==0.9.54" }, - { name = "pydantic", specifier = "==2.11.7" }, - { name = "seleniumbase", specifier = "==4.40.0" }, + { name = "fastapi", extras = ["standard"], specifier = "==0.115.*" }, + { name = "pyautogui", specifier = "==0.9.*" }, + { name = "pydantic", specifier = "==2.11.*" }, + { name = "seleniumbase", specifier = "==4.*" }, { name = "uvicorn", specifier = "==0.35.0" }, ]