### Example Docker Build Command Source: https://camoufox.com/development/docker An example command demonstrating how to run a Docker build for multiple target platforms and architectures. Build artifacts are written to the 'dist/' folder. ```bash $ docker run -v "$(pwd)/dist:/app/dist" camoufox-builder --target windows macos linux --arch x86_64 arm64 i686 ``` -------------------------------- ### Install Xvfb on Arch-based systems Source: https://camoufox.com/python/virtual-display Installs the Xvfb package on Arch-based Linux distributions using pacman. ```bash sudo pacman -S xorg-server-xvfb ``` -------------------------------- ### Install Xvfb on Debian-based systems Source: https://camoufox.com/python/virtual-display Installs the Xvfb package on Debian-based Linux distributions using apt-get. ```bash sudo apt-get install xvfb ``` -------------------------------- ### Setup Vanilla Firefox with Patches Source: https://camoufox.com/development/workflow Use this command to set up a clean Firefox environment with minimal patches applied. This is a foundational step before applying further modifications. ```bash make ff-dbg ``` -------------------------------- ### Bootstrap Camoufox Build System Source: https://camoufox.com/development/buildcli Bootstrap the Camoufox build system. This is a one-time setup process required before building. ```bash make bootstrap ``` -------------------------------- ### Sync API Initialization Source: https://camoufox.com/python/usage Initialize Camoufox using the synchronous API. This is the standard way to start a browser session for most use cases. ```APIDOC ## Sync API Initialization ### Description Initializes the Camoufox browser using the synchronous API. ### Method `Camoufox()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from camoufox.sync_api import Camoufox with Camoufox() as browser: page = browser.new_page() page.goto("https://example.com") ``` ### Response #### Success Response (200) Browser instance is created and ready for use. #### Response Example None ``` -------------------------------- ### Launch Camoufox Server via CLI Source: https://camoufox.com/python/remote-server Use this command to start the Camoufox server directly from your terminal. ```bash python -m camoufox server ``` -------------------------------- ### Verify Xvfb installation Source: https://camoufox.com/python/virtual-display Checks if the Xvfb executable is installed and accessible in the system's PATH. ```bash $ which Xvfb /usr/bin/Xvfb ``` -------------------------------- ### Install Camoufox Package Source: https://camoufox.com/python/installation Installs the camoufox package with optional geoip support for enhanced proxy functionality. The geoip extra downloads an additional dataset for location-based services. ```bash pip install -U camoufox[geoip] ``` -------------------------------- ### Camoufox Usage with GeoIP and Proxies Source: https://camoufox.com/python/geoip Demonstrates how to initialize Camoufox with GeoIP enabled and configure it to use a proxy server. This setup is useful for spoofing IP addresses and associated location data. ```python with Camoufox( geoip=True, proxy={ 'server': 'http://thordata.com:8080', 'username': 'username', 'password': 'password' } ) as browser: page = browser.new_page() page.goto("https://www.browserscan.net") ``` -------------------------------- ### Install Camoufox with GeoIP Extra Source: https://camoufox.com/python/geoip Install Camoufox including the GeoIP extra using pip. This command ensures all necessary dependencies for GeoIP functionality are included. ```bash pip install -U "camoufox[geoip]" ``` -------------------------------- ### Run Camoufox headlessly using Sync API Source: https://camoufox.com/python/virtual-display Launches Camoufox in a virtual display using the synchronous API. Ensure Xvfb is installed and running. ```python from camoufox.sync_api import Camoufox with Camoufox( headless="virtual" ) as browser: page = browser.new_page() page.goto("https://example.com") ``` -------------------------------- ### Run Camoufox headlessly using Async API Source: https://camoufox.com/python/virtual-display Launches Camoufox in a virtual display using the asynchronous API. Ensure Xvfb is installed and running. ```python from camoufox.async_api import AsyncCamoufox async with AsyncCamoufox( headless="virtual" ) as browser: page = await browser.new_page() await page.goto("https://example.com") ``` -------------------------------- ### Install Firefox Dependencies on Arch-based Linux Source: https://camoufox.com/python/installation Installs necessary Firefox dependencies for Camoufox on Arch-based Linux distributions. This includes graphical, audio, and core libraries. ```bash sudo pacman -S gtk3 libx11 libxcb cairo libasound alsa-lib ``` -------------------------------- ### Clone Camoufox Repository Source: https://camoufox.com/development/buildcli Clone the Camoufox repository to your local machine. Ensure you have Git installed. ```bash git clone --depth 1 https://github.com/daijro/camoufox cd camoufox ``` -------------------------------- ### Install Firefox Dependencies on Debian-based Linux Source: https://camoufox.com/python/installation Installs essential Firefox dependencies required for Camoufox on Debian-based Linux distributions. These packages are necessary for graphical and audio functionalities. ```bash sudo apt install -y libgtk-3-0 libx11-xcb1 libasound2 ``` -------------------------------- ### Launch Camoufox Server with Configuration Source: https://camoufox.com/python/remote-server Configure server launch options programmatically, including headless mode, geoip, proxy settings, port, and websocket path. ```python from camoufox.server import launch_server launch_server( headless=True, geoip=True, proxy={ 'server': 'http://example.com:8080', 'username': 'username', 'password': 'password' }, port=1234, ws_path='hello' ) ``` -------------------------------- ### Camoufox Build CLI Parameters Source: https://camoufox.com/development/buildcli Command-line options for the multibuild.py script, including target platforms, architectures, and build options. ```bash Options: -h, --help show this help message and exit --target {linux,windows,macos} [{linux,windows,macos} ...] Target platforms to build --arch {x86_64,arm64,i686} [{x86_64,arm64,i686} ...] Target architectures to build for each platform --bootstrap Bootstrap the build system --clean Clean the build directory before starting Example: $ python3 multibuild.py --target linux windows macos --arch x86_64 arm64 ``` -------------------------------- ### Build Camoufox Source Source: https://camoufox.com/development/buildcli Build the Camoufox source code. This command should be run after cloning the repository. ```bash make dir ``` -------------------------------- ### Load Custom Addons in Camoufox Source: https://camoufox.com/fingerprint/addons Load custom addons by passing a list of extracted addon folder paths to the `addons` parameter. Ensure `.xpi` files are renamed to `.zip`, extracted, and then the folder path is provided. ```python from camoufox.sync_api import Camoufox with Camoufox(addons=['/path/to/addon', '/path/to/addon2']) as browser: page = browser.new_page() ``` -------------------------------- ### Initialize Camoufox (Sync API) Source: https://camoufox.com/python/usage Use this snippet to initialize Camoufox with the synchronous Playwright API. Ensure Camoufox is imported from camoufox.sync_api. ```python from camoufox.sync_api import Camoufox with Camoufox() as browser: page = browser.new_page() page.goto("https://example.com") ``` -------------------------------- ### Run Docker Build Using Local .mozbuild Directory Source: https://camoufox.com/development/docker Use this command to run the Docker build when you want to utilize your host's local .mozbuild directory. It mounts the directory with read-write permissions. ```bash docker run \ -v "$HOME/.mozbuild":/root/.mozbuild:rw,z \ -v "$(pwd)/dist:/app/dist" \ camoufox-builder \ --target \ --arch ``` -------------------------------- ### Build Docker Image for Camoufox Source: https://camoufox.com/development/docker Create the Docker image that contains Firefox's source code. This is the first step before building Camoufox. ```bash docker build -t camoufox-builder . ``` -------------------------------- ### Initialize Camoufox (Async API) Source: https://camoufox.com/python/usage Use this snippet to initialize Camoufox with the asynchronous Playwright API. Ensure AsyncCamoufox is imported from camoufox.async_api. ```python from camoufox.async_api import AsyncCamoufox async with AsyncCamoufox() as browser: page = await browser.new_page() await page.goto("https://example.com") ``` -------------------------------- ### Build and Package Camoufox Source: https://camoufox.com/development/buildcli Build and package Camoufox for specified targets and architectures. This command initiates the final build process. ```bash python3 multibuild.py --target linux windows macos --arch x86_64 arm64 i686 ``` -------------------------------- ### Create a Persistent Browser Context in Camoufox Source: https://camoufox.com/python/usage Set up a persistent browser context, which requires a `user_data_dir`. This allows for maintaining state across sessions. ```python with Camoufox( persistent_context=True, user_data_dir='/path/to/profile/dir', ) as context: ... ``` -------------------------------- ### Run Camoufox Project Source: https://camoufox.com/development/tools Run the Camoufox project to test changes. This command executes the compiled project. ```bash make run ``` -------------------------------- ### Async API Initialization Source: https://camoufox.com/python/usage Initialize Camoufox using the asynchronous API. This is suitable for applications that leverage Python's async capabilities. ```APIDOC ## Async API Initialization ### Description Initializes the Camoufox browser using the asynchronous API. ### Method `AsyncCamoufox()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from camoufox.async_api import AsyncCamoufox async with AsyncCamoufox() as browser: page = await browser.new_page() await page.goto("https://example.com") ``` ### Response #### Success Response (200) Asynchronous browser instance is created and ready for use. #### Response Example None ``` -------------------------------- ### Generate Random BrowserForge Fingerprint with Camoufox Source: https://camoufox.com/python/browserforge Use this snippet to initialize Camoufox with random BrowserForge fingerprints based on specified OS and screen constraints. This is the default and recommended method. ```python from camoufox.sync_api import Camoufox from browserforge.fingerprints import Screen with Camoufox( os=('windows', 'macos', 'linux'), screen=Screen(max_width=1920, max_height=1080), ) as browser: page = browser.new_page() page.goto("https://example.com/") ``` -------------------------------- ### Run Camoufox Build in Docker Source: https://camoufox.com/development/docker Build Camoufox patches for a target platform and architecture using the Docker image. Mount the local 'dist' directory to store build artifacts. ```bash docker run -v "$(pwd)/dist:/app/dist" camoufox-builder --target --arch ``` -------------------------------- ### Run Firefox in Headless Mode Source: https://camoufox.com/development/workflow Use this command to run Firefox in headless mode, which is useful for automated testing. The `--headless` flag allows execution without a graphical interface, and redirects are printed to the console for analysis. ```bash make run args="--headless https://test.com" ``` -------------------------------- ### Loading Addons Source: https://camoufox.com/python/usage Specify a list of Firefox addons to use with Camoufox. Addons must be paths to extracted addon folders. ```APIDOC ## addons **Type:** `Optional[List[str]]` List of Firefox addons to use. Must be paths to extracted addons. To load an `.xpi` file, rename it to a `.zip` file, extract it, and pass the extracted folder. ```python addons = ["/path/to/addon1", "/path/to/addon2"] with Camoufox(addons=addons) as browser: ... ``` ``` -------------------------------- ### Build Camoufox Project Source: https://camoufox.com/development/tools Build the Camoufox project after making changes. This command compiles the project to test modifications. ```bash make build ``` -------------------------------- ### Specify WebGL Configuration Source: https://camoufox.com/python/usage Set a specific WebGL vendor and renderer pair for the fingerprint. The combination must be supported for the target OS to avoid leaks. ```python with Camoufox( webgl_config=("Apple", "Apple M1, or similar"), os="macos", ) as browser: ... ``` -------------------------------- ### Load Custom Firefox Addons with Camoufox Source: https://camoufox.com/python/usage Specify a list of custom Firefox addons to be used by Camoufox. Addons must be provided as paths to extracted addon folders. ```python addons = ["/path/to/addon1", "/path/to/addon2"] with Camoufox(addons=addons) as browser: ... ``` -------------------------------- ### Run Developer UI Source: https://camoufox.com/development/tools Access the developer UI to manage patches. This UI allows for editing, creating, and removing patches. ```bash make edits ``` -------------------------------- ### Configuration - Headless Parameter Source: https://camoufox.com/python/usage Control whether the browser runs in headless mode. ```APIDOC ## Configuration - Headless Parameter ### Description Determines whether the browser instance should run in headless mode (without a visible UI). For Linux users, setting this to 'virtual' utilizes Xvfb for a virtual display. ### Method `Camoufox(headless=...)` or `AsyncCamoufox(headless=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **headless** (`Optional[Union[bool, Literal['virtual']]]`) - Required/Optional - Whether to run the browser in headless mode. Defaults to False. If you are running linux, passing 'virtual' will use Xvfb. ### Request Example ```python # Run in headless mode with Camoufox(headless=True) as browser: ... # Run in headless mode on Linux using Xvfb with Camoufox(headless='virtual') as browser: ... ``` ### Response #### Success Response (200) Browser initialized in the specified headless mode. #### Response Example None ``` -------------------------------- ### Configuration - Humanize Parameter Source: https://camoufox.com/python/usage Enable or customize humanized cursor movement. ```APIDOC ## Configuration - Humanize Parameter ### Description Humanizes the cursor movement during interactions. You can enable it with default settings or specify a maximum duration for the movement. ### Method `Camoufox(humanize=...)` or `AsyncCamoufox(humanize=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **humanize** (`Optional[Union[bool, float]]`) - Required/Optional - Humanize the cursor movement. Takes either `True`, or the MAX duration in seconds of the cursor movement. ### Request Example ```python # Enable humanization with default settings with Camoufox(humanize=True) as browser: ... # Set a custom max duration for cursor movement with Camoufox(humanize=2.0) as browser: ... ``` ### Response #### Success Response (200) Browser initialized with humanized cursor movement enabled. #### Response Example None ``` -------------------------------- ### Camoufox CLI Usage Source: https://camoufox.com/python/installation Displays the command-line interface usage for Camoufox, outlining available options and commands such as fetch, path, remove, server, test, and version. ```text Usage: python -m camoufox [OPTIONS] COMMAND [ARGS]... Options: --help Show this message and exit. Commands: fetch Fetch the latest version of Camoufox path Display the path to the Camoufox executable remove Remove all downloaded files server Launch a Playwright server test Open the Playwright inspector version Display the current version ``` -------------------------------- ### Download Camoufox Browser Source: https://camoufox.com/python/installation Fetches the latest version of the Camoufox browser. Use the appropriate command based on your operating system. ```bash camoufox fetch ``` ```bash python3 -m camoufox fetch ``` ```bash python -m camoufox fetch ``` -------------------------------- ### Device Rotation - OS Parameter Source: https://camoufox.com/python/usage Configure the operating system for device fingerprint generation. ```APIDOC ## Device Rotation - OS Parameter ### Description Specifies the operating system to be used for generating device fingerprints. You can choose a specific OS or a list of OSs to randomly select from. ### Method `Camoufox(os=...)` or `AsyncCamoufox(os=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **os** (`Optional[ListOrString]`) - Required/Optional - Operating system to use for the fingerprint generation. Can be "windows", "macos", "linux", or a list to randomly choose from. By default, Camoufox will randomly choose from a list of all three. ### Request Example ```python # Use a specific OS with Camoufox(os="windows") as browser: ... # Randomly choose from a list of OS with Camoufox(os=["windows", "macos", "linux"]) as browser: ... ``` ### Response #### Success Response (200) Browser initialized with the specified OS for fingerprinting. #### Response Example None ``` -------------------------------- ### Configure OS for Fingerprinting Source: https://camoufox.com/python/usage Specify the operating system for fingerprint generation. Accepts a single OS string or a list for random selection. ```python # Use a specific OS with Camoufox(os="windows") as browser: ... ``` ```python # Randomly choose from a list of OS with Camoufox(os=["windows", "macos", "linux"]) as browser: ... ``` -------------------------------- ### Initialize Browser Fingerprint Detection Source: https://camoufox.com/stealth This script initializes the browser fingerprint detection by loading the Bowser library and then calling the loadFp function. It ensures the script runs after the DOM is fully loaded. ```javascript function loadFp(){ try{ var b=bowser.parse(navigator.userAgent); if(b.browser.name&&b.os.name){ var s=' Right now, any website you visit can see you are using '+b.browser.name+' on '+b.os.name+''; try{ var c=document.createElement('canvas'),gl=c.getContext('webgl'); if(gl){ var d=gl.getExtension('WEBGL_debug_renderer_info'); if(d){ var r=gl.getParameter(d.UNMASKED_RENDERER_WEBGL) .replace(/^ANGLE \(([^,]+),\s*/,'') .replace(/\s*Direct3D[\d]*\s*vs_[\d_]+\s*ps_[\d_]+.*$/i,'') .replace(/,?\s*D3D[\d]*[-\d.]*\)?$/i,'') .replace(/\)?$/,'') .replace(/^(Google Inc\.|Intel Inc\.|NVIDIA Corporation|ATI Technologies Inc\.|AMD|Mesa(\/X\.org)?|VMware, Inc\.|Apple),?\s*/i,'') .replace(/\s*(OpenGL Engine|, or similar)$/gi,'') .replace(/\/PCIe\/SSE2|,\s*OpenGL ES.*$/gi,'') .replace(/\(R\)|\(TM\)/gi,'') .replace(/^Intel,?\s*Intel/i,'Intel') .replace(/\s+/g,' ').trim(); if(r)s+=', running on '+r+''; } } }catch(e){} var el=document.getElementById('fp-sentence'); el.innerHTML=s+'.'; setTimeout(function(){el.style.opacity='1';},50); } }catch(e){} } function init(){ var sc=document.createElement('script'); sc.src='https://cdn.jsdelivr.net/npm/bowser@2/bundled.min.js'; sc.onload=loadFp; document.head.appendChild(sc); } if(document.readyState==='complete'){ init(); }else{ window.addEventListener('load',init); } ``` -------------------------------- ### Headless Mode Source: https://camoufox.com/python/usage Run Camoufox in headless mode on Linux. This is useful for running browser instances without a visible UI. ```APIDOC ## Run in headless mode on linux with Camoufox(headless="virtual") as browser: ... ``` -------------------------------- ### Edit Camoufox Configuration File Source: https://camoufox.com/development/workflow Use this command to open the `camoufox.cfg` file in your system's default editor. This allows for modification of Camoufox settings, such as enabling or disabling specific features. ```bash make edit-cfg ``` -------------------------------- ### Run in Headless Mode Source: https://camoufox.com/python/usage Control whether the browser runs in headless mode. For Linux, 'virtual' can be used to enable Xvfb. ```python # Run in headless mode with Camoufox(headless=True) as browser: ... ``` ```python # Run in headless mode with virtual display on Linux with Camoufox(headless='virtual') as browser: ... ``` -------------------------------- ### Run Camoufox in Headless Mode on Linux Source: https://camoufox.com/python/usage Configure Camoufox to run in headless mode, suitable for Linux environments. This mode is useful for running browser automation without a visible UI. ```python with Camoufox(headless="virtual") as browser: ... ``` -------------------------------- ### Persistent Context Source: https://camoufox.com/python/usage Create a persistent browser context, which requires a `user_data_dir` to be specified. This allows for session persistence across multiple runs. ```APIDOC ## persistent_context **Type:** `Optional[bool]` Whether to create a persistent context. Requires `user_data_dir`. ```python with Camoufox( persistent_context=True, user_data_dir='/path/to/profile/dir', ) as context: ... ``` ``` -------------------------------- ### Inject Fingerprint Properties with Camoufox Source: https://camoufox.com/fingerprint Use this snippet to initialize Camoufox with custom fingerprint properties. The configuration is passed as a JSON object to the Python interface. ```python with Camoufox(config={"property": "value"}) as browser: ``` -------------------------------- ### Device Rotation - WebGL Config Parameter Source: https://camoufox.com/python/usage Specify a custom WebGL vendor and renderer pair for the device fingerprint. ```APIDOC ## Device Rotation - WebGL Config Parameter ### Description Allows you to set a specific WebGL vendor and renderer pair for the device fingerprint. Ensure the combination is supported for the target OS to avoid fingerprint leaks. ### Method `Camoufox(webgl_config=...)` or `AsyncCamoufox(webgl_config=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **webgl_config** (`Optional[Tuple[str, str]]`) - Required/Optional - Use a specific WebGL vendor/renderer pair. Passed as a tuple of (vendor, renderer). The vendor & renderer combination must be supported for the target `os` or this will cause leaks. ### Request Example ```python with Camoufox( webgl_config=("Apple", "Apple M1, or similar"), os="macos", ) as browser: ... ``` ### Response #### Success Response (200) Browser initialized with the specified WebGL configuration. #### Response Example None ``` -------------------------------- ### Main World Evaluation Source: https://camoufox.com/python/usage Enable or disable script injection into the main world, prefixed with `mw:`. This allows for direct DOM manipulation. ```APIDOC ## main_world_eval **Type:** `Optional[bool]` Whether to inject scripts into the main world when prefixed with `mw:` ```python with Camoufox(main_world_eval=True) as browser: page = browser.new_page() page.goto("https://example.com") # Modify the DOM page.evaluate("mw:document.querySelector('h1').remove()") ``` [!ref See more info](/python/main-world-eval.md) ``` -------------------------------- ### Setting Window Size Source: https://camoufox.com/python/usage Define the browser window dimensions (width, height). This also positions the window at the center of the screen. Note: Using a fixed window size can be a fingerprinting risk. ```APIDOC ## window **Type:** `Optional[Tuple[int, int]]` Set the window size in (width, height) pixels. This will also set the `window.screenX` and `window.screenY` properties to position the window at the center of the generated screen. !!! Camoufox will automatically generate a window size for you. Using a fixed window size can lead to fingerprinting. Do not set the window size to a fixed value unless for debugging purposes. !!! ```python with Camoufox(window=(1282, 955)) as browser: ... ``` ``` -------------------------------- ### Locale Settings Source: https://camoufox.com/python/usage Configure the locale(s) for the browser. This can be a single locale string, a comma-separated string, or a list of strings. The first locale is used for the Intl API. ```APIDOC ## locale **Type:** `Optional[Union[str, List[str]]]` Locale(s) to use in Camoufox. Can be a list of strings, or a single string separated by a comma. The first locale in the list will be used for the Intl API. ```python # Use a single locale with Camoufox(locale="en-US") as browser: ... # Generate a language based on the distribution of speakers the US with Camoufox(locale="US") as browser: ... # Use multiple accepted locales with Camoufox(locale=["en-US", "fr-FR", "de-DE"]) as browser: ... with Camoufox(locale="en-US,fr-FR,de-DE") as browser: ... ``` ``` -------------------------------- ### Inject Custom BrowserForge Fingerprint into Camoufox Source: https://camoufox.com/python/browserforge This snippet demonstrates how to inject a custom BrowserForge fingerprint into Camoufox. While functional, passing OS and screen constraints to Camoufox directly is recommended and will be deprecated in the future. ```python from camoufox.sync_api import Camoufox from browserforge.fingerprints import FingerprintGenerator fg = FingerprintGenerator(browser='firefox') # Launch Camoufox with a random Firefox fingerprint with Camoufox(fingerprint=fg.generate()) as browser: page = browser.new_page() page.goto("https://example.com/") ``` -------------------------------- ### Camoufox WebGL Configuration Placeholder Source: https://camoufox.com/tests/webgl.html This snippet represents the placeholder for WebGL configuration data within Camoufox. It is an empty JSON object. ```json {} ``` -------------------------------- ### Override Camoufox Configuration with Dictionary Source: https://camoufox.com/python/config Pass a dictionary to the `config` parameter to override default settings. This is useful for enabling features not yet implemented in the library. Camoufox will warn if you manually set properties it manages internally. ```python from camoufox.sync_api import Camoufox with Camoufox( config={ 'webrtc:ipv4': '123.45.67.89', 'webrtc:ipv6': 'e791:d37a:88f6:48d1:2cad:2667:4582:1d6d', } ) as browser: page = browser.new_page() page.goto("https://www.browserscan.net/webrtc") ``` -------------------------------- ### Enable Main World Evaluation in Camoufox Source: https://camoufox.com/python/main-world-eval Initialize Camoufox with `main_world_eval=True` to allow JavaScript execution in the main world. This is necessary for modifying the DOM. ```python with Camoufox(main_world_eval=True) as browser: page = browser.new_page() page.goto("https://example.com/") ``` -------------------------------- ### Set Multiple Accepted Locales in Camoufox (List) Source: https://camoufox.com/python/usage Provide a list of locales to Camoufox, allowing the browser to use any of the specified languages. The first locale in the list is used for the Intl API. ```python # Use multiple accepted locales with Camoufox(locale=["en-US", "fr-FR", "de-DE"]) as browser: ... ``` -------------------------------- ### Set Multiple Accepted Locales in Camoufox (String) Source: https://camoufox.com/python/usage Configure Camoufox with multiple accepted locales using a comma-separated string. This provides flexibility in language settings for the browser. ```python with Camoufox(locale="en-US,fr-FR,de-DE") as browser: ... ``` -------------------------------- ### Add Custom Fonts for Fingerprinting Source: https://camoufox.com/python/usage Provide a list of font family names to be loaded into Camoufox, supplementing the default fonts for the target OS. ```python custom_fonts = ["Arial", "Helvetica", "Times New Roman"] with Camoufox(fonts=custom_fonts) as browser: ... ``` -------------------------------- ### Enable Humanized Cursor Movement Source: https://camoufox.com/python/usage Humanize cursor movement by setting `humanize` to `True` for default settings or a float for a custom maximum duration in seconds. ```python # Enable humanization with default settings with Camoufox(humanize=True) as browser: ... ``` ```python # Set a custom max duration for cursor movement with Camoufox(humanize=2.0) as browser: ... ``` -------------------------------- ### Return JSON Serializable Data from Main World Source: https://camoufox.com/python/main-world-eval Evaluate JavaScript in the main world and return JSON serializable data. Note that returning node references is not supported. ```python >>> page.evaluate("mw:{key: 'value'}") {'key': 'value'} ``` -------------------------------- ### Connect to Remote Camoufox Server Source: https://camoufox.com/python/remote-server Connect to a running Camoufox websocket server using Playwright's `connect` method. Ensure the endpoint URL matches the server's configured port and path. ```python from playwright.sync_api import sync_playwright with sync_playwright() as p: # Example endpoint browser = p.firefox.connect('ws://localhost:1234/hello') page = browser.new_page() ... ``` -------------------------------- ### Device Rotation - Config Parameter Source: https://camoufox.com/python/usage Override individual Camoufox configuration properties using a dictionary. ```APIDOC ## Device Rotation - Config Parameter ### Description Provides an advanced way to override specific Camoufox configuration properties by passing them as a dictionary. Use with caution as the library is designed to manage these properties. ### Method `Camoufox(config=...)` or `AsyncCamoufox(config=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **config** (`Optional[Dict[str, Any]]`) - Required/Optional - If needed, individual Camoufox config properties can be overridden by passing them as a dictionary to the `config` parameter. This can be used to enable features that have not yet been implemented into the Python library. ### Request Example ```python # Example of overriding a config property (specific property depends on implementation) with Camoufox(config={"some_property": "some_value"}) as browser: ... ``` ### Response #### Success Response (200) Browser initialized with custom configuration overrides. #### Response Example None ``` -------------------------------- ### Enable Main World Script Injection in Camoufox Source: https://camoufox.com/python/usage Configure Camoufox to inject scripts into the main world when they are prefixed with 'mw:'. This allows for direct DOM manipulation. ```python with Camoufox(main_world_eval=True) as browser: page = browser.new_page() page.goto("https://example.com") # Modify the DOM page.evaluate("mw:document.querySelector('h1').remove()") ``` -------------------------------- ### Override Camoufox Configuration Source: https://camoufox.com/python/usage Advanced usage: override individual Camoufox configuration properties by passing them as a dictionary to the `config` parameter. Use with caution. ```python with Camoufox(config={"some_property": "value"}) as browser: ... ``` -------------------------------- ### Set Camoufox Window Size Source: https://camoufox.com/python/usage Define the browser window dimensions (width, height) in pixels. Note that using a fixed window size can increase fingerprinting risks. ```python with Camoufox(window=(1282, 955)) as browser: ... ``` -------------------------------- ### Define Browser Voices Source: https://camoufox.com/fingerprint/voices Configure the array of voices available to the Web Speech API. Each voice object must include `isLocalService`, `isDefault`, `voiceUri`, `name`, and `lang`. ```json [ { "isLocalService": true, "isDefault": true, "voiceUri": "Ting-Ting", "name": "Ting-Ting", "lang": "zh-CN" }, ... ] ``` -------------------------------- ### Geolocation (geoip) Source: https://camoufox.com/python/usage Set the geolocation for the browser. You can provide a specific IP address or set it to `True` to automatically detect the IP. This helps in preventing proxy detection. ```APIDOC ## geoip **Type:** `Optional[Union[str, bool]]` Calculates longitude, latitude, timezone, country, & locale based on the IP address. Pass the target IP address to use, or `True` to find the IP address automatically. [!ref Geolocation & Proxies](/python/geoip.md) ```python # Use a specific IP address with Camoufox(geoip="203.0.113.0", proxy=...) as browser: ... # Automatically find the IP address with Camoufox(geoip=True, proxy=...) as browser: ... ``` ``` -------------------------------- ### Excluding Default Addons Source: https://camoufox.com/python/usage Exclude specific default addons provided by Camoufox. This is done by passing a list of `camoufox.DefaultAddons` enums. ```APIDOC ## exclude_addons **Type:** `Optional[List[DefaultAddons]]` Exclude the default addons. Passed as a list of `camoufox.DefaultAddons` enums. [!ref Default addons](/fingerprint/addons.md#default-addons) ``` -------------------------------- ### Constrain Screen Dimensions Source: https://camoufox.com/python/usage Limit the screen dimensions for the generated fingerprint using the Screen class. Note that this has a light impact on the actual window size. ```python from browserforge.fingerprints import Screen constrains = Screen(max_width=1920, max_height=1080) with Camoufox(screen=constrains) as browser: ... ``` -------------------------------- ### Set Fake Voice Playback Rate Source: https://camoufox.com/fingerprint/voices Configure the playback rate of a fake voice in characters per second using `voices:fakeCompletion:charsPerSecond`. The default is `12.5` characters per second. ```json 15.0 ``` -------------------------------- ### Block System Voices Source: https://camoufox.com/fingerprint/voices Set `voices:blockIfNotDefined` to `true` to prevent system-defined voices from being used. ```json true ``` -------------------------------- ### Device Rotation - Screen Parameter Source: https://camoufox.com/python/usage Constrain the screen dimensions for the generated device fingerprint. ```APIDOC ## Device Rotation - Screen Parameter ### Description Limits the screen dimensions (width and height) for the generated device fingerprint. Note that this may not precisely control the browser window size. ### Method `Camoufox(screen=...)` or `AsyncCamoufox(screen=...)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **screen** (`Optional[Screen]`) - Required/Optional - Constrains the screen dimensions of the generated fingerprint. Takes a `browserforge.fingerprints.Screen` instance. ### Request Example ```python from browserforge.fingerprints import Screen constrains = Screen(max_width=1920, max_height=1080) with Camoufox(screen=constrains) as browser: ... ``` ### Response #### Success Response (200) Browser initialized with constrained screen dimensions for fingerprinting. #### Response Example None ``` -------------------------------- ### Enable Cache Source: https://camoufox.com/python/usage Control whether Camoufox should cache previous pages and requests. Disabled by default to conserve memory. Enabling cache is required for `page.go_back()` and `page.go_forward()`. ```APIDOC ## enable_cache **Type:** `Optional[bool]` Whether to cache previous pages, requests, etc. Disabled by default as it uses more memory. !!! Keeping this disabled will not allow you to use the `page.go_back()` or `page.go_forward()` methods. !!! ```python with Camoufox(enable_cache=True) as browser: ... ``` ``` -------------------------------- ### Enable Caching in Camoufox Source: https://camoufox.com/python/usage Enable caching for previous pages and requests to potentially improve performance. Caching is disabled by default to conserve memory. Enabling cache is required for `page.go_back()` and `page.go_forward()`. ```python with Camoufox(enable_cache=True) as browser: ... ``` -------------------------------- ### Set Locale Based on Country Distribution in Camoufox Source: https://camoufox.com/python/usage Use a country code, like 'US', to set the locale based on the distribution of language speakers in that country. This can provide a more natural language setting. ```python # Generate a language based on the distribution of speakers the US with Camoufox(locale="US") as browser: ... ``` -------------------------------- ### Block All Images in Camoufox Source: https://camoufox.com/python/usage Prevent Camoufox from loading any images by setting `block_images=True`. This can help reduce bandwidth usage and proxy costs. ```python with Camoufox(block_images=True) as browser: ... ``` -------------------------------- ### Exclude Default Addons in Camoufox Source: https://camoufox.com/fingerprint/addons Exclude default addons, such as uBlock Origin, by using the `exclude_addons` parameter with the `DefaultAddons` enum. This is useful when you want to manage your own ad-blocking or privacy filters. ```python from camoufox.sync_api import Camoufox from camoufox import DefaultAddons with Camoufox(exclude_addons=[DefaultAddons.UBO]) as browser: page = browser.new_page() ``` -------------------------------- ### Configure Geolocation with a Specific IP in Camoufox Source: https://camoufox.com/python/usage Set the geolocation for Camoufox using a specific IP address. This helps in matching your location with the target IP to prevent proxy detection. ```python # Use a specific IP address with Camoufox(geoip="203.0.113.0", proxy=...) as browser: ... ``` -------------------------------- ### Block Images Source: https://camoufox.com/python/usage Prevent all image requests from loading. This can help reduce bandwidth and proxy usage. ```APIDOC ## block_images **Type:** `Optional[bool]` Blocks all requests to images. This can help save your proxy usage. ```python with Camoufox(block_images=True) as browser: ... ``` ``` -------------------------------- ### Set a Single Locale in Camoufox Source: https://camoufox.com/python/usage Configure Camoufox to use a specific locale, such as 'en-US'. This affects the Intl API and language preferences. ```python # Use a single locale with Camoufox(locale="en-US") as browser: ... ``` -------------------------------- ### Automatically Detect Geolocation in Camoufox Source: https://camoufox.com/python/usage Enable automatic geolocation detection in Camoufox by setting `geoip=True`. The library will find the IP address automatically to match your location. ```python # Automatically find the IP address with Camoufox(geoip=True, proxy=...) as browser: ... ```