### Copy Environment Example Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Copy the example environment file to create your own configuration. ```bash cp .env.example .env ``` -------------------------------- ### Install Patchright Browser Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Install the Patchright browser engine. ```bash patchright install chromium ``` -------------------------------- ### Set Up Python Virtual Environment Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Create and activate a Python virtual environment, then install project dependencies. ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ``` -------------------------------- ### Proxy Configuration Example Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Example content for the proxies.txt file, specifying proxy URLs in various formats. Ensure sufficient proxies of required protocols (HTTP/HTTPS, SOCKS5) are provided. ```text http://proxy1.example.com:8080 http://proxy2.example.com:8080 http://username:password@proxy3.example.com:8080 http://username:password@proxy4.example.com:8080 socks5://username:password@proxy5.example.com:8080 ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Install Playwright and its dependencies for browser automation. ```bash playwright install # On Linux also run: playwright install-deps ``` -------------------------------- ### Run Benchmark Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Execute the main Python script to start the browser benchmark. ```bash python main.py ``` -------------------------------- ### Fetch Camoufox Browser Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Download and install the Camoufox browser. Ensure necessary system libraries are installed on Linux. ```bash # Windows camoufox fetch # Linux python -m camoufox fetch sudo apt install -y libgtk-3-0 libx11-xcb1 libasound2 ``` -------------------------------- ### Configure AdsPower API Key Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Download and install AdsPower, enable its local API, and set the API key in the .env file. AdsPower must remain running. ```bash # Edit .env with your proxy settings if needed ``` -------------------------------- ### Extend BrowserEngine Base Class Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Create a new browser engine by inheriting from the BrowserEngine base class and implementing the start and navigate methods. For Playwright or Selenium specific implementations, extend PlaywrightBase or SeleniumBase respectively. ```python class CustomEngine(BrowserEngine): async def start(self) -> None: # Initialize browser async def navigate(self, url: str) -> Dict[str, Any]: # Navigation logic ``` ```python class CustomPlaywrightBasedEngine(PlaywrightBase): ... ``` ```python class CustomSeleniumBasedEngine(SeleniumBase): ... ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Clone the project repository and change into the project directory. ```bash git clone https://github.com/techinz/browsers-benchmark.git cd browsers-benchmark ``` -------------------------------- ### Proxy and Performance Environment Variables Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Configure proxy settings and performance parameters using environment variables in a .env file. Proxy configuration is highly recommended. ```bash # Proxy Configuration (highly recommended to enable) PROXY_ENABLED=true PROXY_FILE_PATH=documents/proxies.txt PROXY_MAX_RETRIES=3 # Performance Settings PAGE_LOAD_TIMEOUT_S=90 PAGE_STABILIZATION_DELAY_S=5 MAX_RETRIES=3 # AdsPower (optional — only needed if running the adspower engine) # Get your API key from AdsPower desktop app: Settings → API ADSPOWER_API_KEY=your_api_key_here ADSPOWER_BASE_URL=http://local.adspower.net:50325 ADSPOWER_GROUP_ID= ``` -------------------------------- ### Register New Browser Engine Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Add the custom browser engine to the engines mapping in config/engines.py. This involves specifying the class and any necessary parameters for its initialization. ```python base_engines = [ { "class": PlaywrightEngine, "params": {"headless": True, "name": "playwright-chrome_headless", "browser_type": "chromium"} }, ... { "class": CustomEngine, "params": {"headless": True, "name": "custom_engine", "browser_type": "chromium"} } ] ``` -------------------------------- ### Add Custom Test Target Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Define a new test target by modifying the benchmark_targets.py configuration file. This involves creating a Target object with its name, URL, and check function. ```python Target( name="custom_site", url="https://example.com", check_function="check_custom_bypass", description="Custom site protection test" ) ``` -------------------------------- ### Create Custom Check Function Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Implement a custom check function in a Python file within utils/targets/ to determine if a target's protection mechanism is bypassed. The function should return a boolean indicating success. ```python from engines.base import BrowserEngine async def check_custom_bypass(engine: BrowserEngine) -> bool: element_found, element_html = await engine.locator('//div[@class="captcha"]') return not element_found # no captcha found - success! ``` -------------------------------- ### Map Custom Check Function Source: https://github.com/techinz/browsers-benchmark/blob/main/README.md Register the custom check function within the checkers mapping in config/benchmark_targets.py. This makes the new check function available for use with defined targets. ```python checkers: Dict[str, Callable] = Field( default_factory=lambda: { "check_cloudflare_bypass": check_cloudflare_bypass, "check_datadome_bypass": check_datadome_bypass, ... "check_custom_bypass": check_custom_bypass, } ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.