Package: kameleo.local-api-client
Kameleo Local API ClientWithKameleo, you can easily create multiple virtual browser profiles to work with multiple accounts. It helps you hide your actual timezone, geolocation, language, IP address and creates natural browser fingerprints to prevent detection by anti-bot systems. Kameleo is compatible withSelenium,Playwright, andPuppeteerframeworks for automating web scraping tasks. This Python package provides convenient access to theLocal APIREST interface of the Kameleo Client. See thearticlein our knowledge base for Getting Started with Kameleo Automation.FeaturesStay completely undetected, so websites wonâ€™t be able to detect that you are using automation toolsStart unlimited number of profiles with different natural browser fingerprintsUse authenticated HTTP/SOCKS/SSH proxies in browsersCreate isolated browsing environments simultaneouslyUse real browser profiles of Chrome, Firefox, Safari and EdgeEdit, Import or Export browser cookiesModify WebRTC parametersModify Geolocation settingsModify Timezone and Language settingsModify WebGL fingerprintModify 2D Canvas fingerprintModify Navigator propertiesModify Screen resolutionNote:You needAutomation packageof Kameleo to access the features described below.Quickstart Guide1. Install packagepip install kameleo.local_api_client2. Start the Kameleo.CLI on your computer./Kameleo.CLI.exe email="your@email.com" password="Pa$$w0rd"3. Start a browser with out-of-the-box fingerprinting protectionfromkameleo.local_api_clientimportKameleoLocalApiClientfromkameleo.local_api_client.builder_for_create_profileimportBuilderForCreateProfileclient=KameleoLocalApiClient()base_profiles=client.search_base_profiles(device_type='desktop',browser_product='chrome')# Create a new profile with recommended settings# for browser fingerprinting protectioncreate_profile_request=BuilderForCreateProfile\.for_base_profile(base_profiles[0].id)\.set_recommended_defaults()\.build()profile=client.create_profile(body=create_profile_request)# Start the browserclient.start_profile(profile.id)# At this point you can automate the browser with your favorite frameworkAutomate Kameleo profiles with SeleniumKameleo gives you the ability to control any supported browser using Selenium. It uses the WebDriver protocol, a W3C specification, and industry-standard to interact with a browser.You need to install the officialSelenium package.fromseleniumimportwebdriver# Connect to the running browser instance using WebDriverkameleo_port=5050options=webdriver.ChromeOptions()options.add_experimental_option('kameleo:profileId',profile.id)driver=webdriver.Remote(command_executor=f'http://localhost:{kameleo_port}/webdriver',options=options)# Use any WebDriver command to drive the browser# and enjoy full protection from bot detection productsdriver.get('https://google.com')The full example can be foundhere.Automate Kameleo profiles with Puppeteer (Chromium-based)Kameleo lets you control Chromium-based browsers (sorry Firefox fans) using thePyppeteer library. In this simple example you can see how to connect to the browser that Kameleo starts.You need to import thePyppeteer library.importpyppeteer# Connect to the browser with Puppeteer through CDPkameleo_port=5050browser_ws_endpoint=f'ws://localhost:{kameleo_port}/puppeteer/{profile.id}'browser=awaitpyppeteer.launcher.connect(browserWSEndpoint=browser_ws_endpoint,defaultViewport=False)page=awaitbrowser.newPage()# Use any Playwright command to drive the browser# and enjoy full protection from bot detection productsawaitpage.goto('https://google.com')The full example can be foundhere.Automate Kameleo profiles with PlaywrightKameleo allows you to control the browser with the officialPlaywright package. It works little bit different with Chromium-based browsers and Firefox, so we provide an example for both. Here we showcase how you can connect to the browser that is already started by Kameleo.You need to import the officialPlaywright package.importplaywrightfromplaywright.sync_apiimportsync_playwrightYou can find more details here:Using Kameleo with Playwright framework â€“ Kameleo Support Center.Chromium-based profiles with Playwright# Connect to the browser with Playwright through CDPkameleo_port=5050browser_ws_endpoint=f'ws://localhost:{kameleo_port}/playwright/{profile.id}'withsync_playwright()asplaywright:browser=playwright.chromium.connect_over_cdp(endpoint_url=browser_ws_endpoint)context=browser.contexts[0]page=context.new_page()# Use any Playwright command to drive the browser# and enjoy full protection from bot detection productspage.goto('https://google.com')The full example can be foundhere.Firefox-based profiles with Playwright# Connect to the browser with Playwrightkameleo_port=5050browser_ws_endpoint=f'ws://localhost:{kameleo_port}/playwright/{profile.id}'withsync_playwright()asplaywright:# The exact path to the bridge executable is subject to change. Here, we use %LOCALAPPDATA%\Programs\Kameleo\pw-bridge.exeexecutable_path_example=path.expandvars(r'%LOCALAPPDATA%\Programs\Kameleo\pw-bridge.exe')browser=playwright.firefox.launch_persistent_context('',# The Playwright framework is not designed to connect to already running# browsers. To overcome this limitation, a tool bundled with Kameleo, named# pw-bridge.exe will bridge the communication gap between the running Firefox# instance and this playwright script.executable_path=executable_path_example,args=[f'-target{browser_ws_endpoint}'],viewport=None)# Kameleo will open the a new page in the default browser context.# NOTE: We DO NOT recommend using multiple browser contexts, as this might interfere#       with Kameleo's browser fingerprint modification features.page=browser.new_page()# Use any Playwright command to drive the browser# and enjoy full protection from bot detection productspage.goto('https://google.com')# Here we need to close the browser object as well, it is not enough just to stop the profileclient.stop_profile(profile.id)browser.close()The full example can be foundhere.Automate mobile profilesKameleo can emulate mobile devices in the custom built Chromium.# Search for a mobile Base Profilesbase_profile_list=client.search_base_profiles(device_type='mobile',os_family='ios',browser_product='safari',language='en-us')# Create a new profile with recommended settings# Choose one of the Base Profiles# Set the launcher to 'chromium' so the mobile profile will be started in Chromium by Kameleocreate_profile_request=BuilderForCreateProfile\.for_base_profile(base_profile_list[0].id)\.set_recommended_defaults()\.set_launcher('chromium')\.build()profile=client.create_profile(body=create_profile_request)# Start the profileclient.start_profile_with_options(profile.id,body={# This allows you to click on elements using the cursor when emulating a touch screen in the browser.# If you leave this out, your script may time out after clicks and fail.'additionalOptions':[{'key':'disableTouchEmulation','value':True,},],})# At this point you can automate the browser with your favorite frameworkThe full example can be foundhere.Example codesSeveral exampleshave been prepared in a different repository to showcase the most interesting features. Feel free to create a pull request to add new example codes.Finding base profilesCreating profiles with custom optionsUpdating profiles with new settingsHow to start a profileUsing Selenium with Local APIUsing Playwright with KameleoUsing Puppeteer with KameleoHow to emulate mobile devicesAdding an HTTP, SOCKS or SSH proxy to profileSaving/Loading a browsing session to/from a .kameleo fileModify and Delete browser cookiesStart profile with extra WebDriver capabilitiesHow to duplicate virtual browser profilesRefresh the browser of the emulated profilesNote:If you are interested in more information about Kameleo, or have encountered an issue with using it, please check out ourHelp Center.EndpointsAvailable API endpoints with exhaustive descriptions and example values are documented on thisSwaggerHubpage. This package has built-inIntelliSensesupport in Visual Studio Code, no extra package installation needed.PackageThis package can be found on PyPI here:kameleo.local-api-client.LicenseThis project is released under MIT License. Please refer the LICENSE.txt for more details.