Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ __pycache__/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
Expand Down
93 changes: 54 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
<img src="https://raw.githubusercontent.com/kameleo-io/local-api-client-python/HEAD/docs/kameleo-logo.png" width="150" align="right" />

# Kameleo Local API Client
With [Kameleo](https://kameleo.io), 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 with [Selenium](https://www.selenium.dev/), [Playwright](https://playwright.dev/), and [Puppeteer](https://pptr.dev/) frameworks for automating web scraping tasks. This Python package provides convenient access to the [Local API](https://app.swaggerhub.com/apis/kameleo-team/kameleo-local-api/) REST interface of the Kameleo Client. See the [article](https://help.kameleo.io/hc/en-us/articles/4418166326417) in our knowledge base for Getting Started with Kameleo Automation.

With [Kameleo](https://kameleo.io), 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 with [Selenium](https://www.selenium.dev/), [Playwright](https://playwright.dev/), and [Puppeteer](https://pptr.dev/) frameworks for automating web scraping tasks. This Python package provides convenient access to the [Local API](https://app.swaggerhub.com/apis/kameleo-team/kameleo-local-api/) REST interface of the Kameleo Client. See the [article](https://help.kameleo.io/hc/en-us/articles/4418166326417) in our knowledge base for Getting Started with Kameleo Automation.

# Features
- Stay completely undetected, so websites won’t be able to detect that you are using automation tools
- Start unlimited number of profiles with different natural browser fingerprints
- Use authenticated HTTP/SOCKS/SSH proxies in browsers
- Create isolated browsing environments simultaneously
- Use real browser profiles of Chrome, Firefox, Safari and Edge
- Edit, Import or Export browser cookies
- Modify WebRTC parameters
- Modify Geolocation settings
- Modify Timezone and Language settings
- Modify WebGL fingerprint
- Modify 2D Canvas fingerprint
- Modify Navigator properties
- Modify Screen resolution

> Note: _You need [Automation package](https://kameleo.io/pricing) of Kameleo to access the features described below._
- Stay completely undetected, so websites won’t be able to detect that you are using automation tools
- Start unlimited number of profiles with different natural browser fingerprints
- Use authenticated HTTP/SOCKS/SSH proxies in browsers
- Create isolated browsing environments simultaneously
- Use real browser profiles of Chrome, Firefox, Safari and Edge
- Edit, Import or Export browser cookies
- Modify WebRTC parameters
- Modify Geolocation settings
- Modify Timezone and Language settings
- Modify WebGL fingerprint
- Modify 2D Canvas fingerprint
- Modify Navigator properties
- Modify Screen resolution

> Note: _You need [Automation package](https://kameleo.io/pricing) of Kameleo to access the features described below._

# Quickstart Guide

## 1. Install package

```
pip install kameleo.local_api_client
```

## 2. Start the Kameleo.CLI on your computer

```
./Kameleo.CLI.exe email="your@email.com" password="Pa$$w0rd"
./Kameleo.CLI email="your@email.com" password="Pa$$w0rd"
```

## 3. Start a browser with out-of-the-box fingerprinting protection

```python
from kameleo.local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
Expand All @@ -61,6 +64,7 @@ client.start_profile(profile.id)
```

# Automate Kameleo profiles with Selenium

Kameleo 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 official [Selenium package](https://pypi.org/project/selenium/).
Expand All @@ -87,6 +91,7 @@ driver.get('https://google.com')
The full example can be found [here](https://github.com/kameleo-io/local-api-examples/blob/master/python/connect_to_selenium/app.py).

# Automate Kameleo profiles with Puppeteer (Chromium-based)

Kameleo lets you control Chromium-based browsers (sorry Firefox fans) using the [Pyppeteer library](https://pypi.org/project/pyppeteer/). In this simple example you can see how to connect to the browser that Kameleo starts.

You need to import the [Pyppeteer library](https://pypi.org/project/pyppeteer/).
Expand All @@ -110,9 +115,11 @@ await page.goto('https://google.com')
The full example can be found [here](https://github.com/kameleo-io/local-api-examples/blob/master/python/connect_with_puppeteer/app.py).

# Automate Kameleo profiles with Playwright

Kameleo allows you to control the browser with the official [Playwright package](https://pypi.org/project/playwright/). 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 official [Playwright package](https://pypi.org/project/playwright/).

```python
import playwright
from playwright.sync_api import sync_playwright
Expand Down Expand Up @@ -145,15 +152,19 @@ The full example can be found [here](https://github.com/kameleo-io/local-api-exa
kameleo_port = 5050
browser_ws_endpoint = f'ws://localhost:{kameleo_port}/playwright/{profile.id}'
with sync_playwright() as playwright:
# The exact path to the bridge executable is subject to change. Here, we use %LOCALAPPDATA%\Programs\Kameleo\pw-bridge.exe
executable_path_example = path.expandvars(r'%LOCALAPPDATA%\Programs\Kameleo\pw-bridge.exe')
# The Playwright framework is not designed to connect to already running
# browsers. To overcome this limitation, a tool bundled with Kameleo, named
# pw-bridge will bridge the communication gap between the running Firefox
# instance and this playwright script.
# The exact path to the bridge executable is subject to change
pw_bridge_path = getenv('PW_BRIDGE_PATH')
if pw_bridge_path == None and system() == 'Windows':
pw_bridge_path = path.expandvars(r'%LOCALAPPDATA%\Programs\Kameleo\pw-bridge.exe')
elif pw_bridge_path == None and system() == 'Darwin':
pw_bridge_path = '/Applications/Kameleo.app/Contents/MacOS/pw-bridge'
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,
executable_path=pw_bridge_path,
args=[f'-target {browser_ws_endpoint}'],
viewport=None)

Expand All @@ -174,6 +185,7 @@ with sync_playwright() as playwright:
The full example can be found [here](https://github.com/kameleo-io/local-api-examples/blob/master/python/connect_with_playwright_to_firefox/app.py).

# Automate mobile profiles

Kameleo can emulate mobile devices in the custom built Chromium.

```python
Expand Down Expand Up @@ -210,35 +222,38 @@ client.start_profile_with_options(profile.id, body={

# At this point you can automate the browser with your favorite framework
```
The full example can be found [here](https://github.com/kameleo-io/local-api-examples/blob/master/python/automate_mobile_profiles_on_desktop/app.py).

The full example can be found [here](https://github.com/kameleo-io/local-api-examples/blob/master/python/automate_mobile_profiles_on_desktop/app.py).

# Example codes

[Several examples](https://github.com/kameleo-io/local-api-examples) have 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 profiles
- Creating profiles with custom options
- Updating profiles with new settings
- How to start a profile
- Using Selenium with Local API
- Using Playwright with Kameleo
- Using Puppeteer with Kameleo
- How to emulate mobile devices
- Adding an HTTP, SOCKS or SSH proxy to profile
- Saving/Loading a browsing session to/from a .kameleo file
- Modify and Delete browser cookies
- Start profile with extra WebDriver capabilities
- How to duplicate virtual browser profiles
- Refresh the browser of the emulated profiles
- Finding base profiles
- Creating profiles with custom options
- Updating profiles with new settings
- How to start a profile
- Using Selenium with Local API
- Using Playwright with Kameleo
- Using Puppeteer with Kameleo
- How to emulate mobile devices
- Adding an HTTP, SOCKS or SSH proxy to profile
- Saving/Loading a browsing session to/from a .kameleo file
- Modify and Delete browser cookies
- Start profile with extra WebDriver capabilities
- How to duplicate virtual browser profiles
- Refresh the browser of the emulated profiles

> Note: _If you are interested in more information about Kameleo, or have encountered an issue with using it, please check out our [Help Center](https://help.kameleo.io/)._


# Endpoints

Available API endpoints with exhaustive descriptions and example values are documented on this [SwaggerHub](https://app.swaggerhub.com/apis/kameleo-team/kameleo-local-api/) page. This package has built-in [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense) support in Visual Studio Code, no extra package installation needed.

# Package

This package can be found on PyPI here: [kameleo.local-api-client](https://pypi.org/project/kameleo.local-api-client/).

# License

This project is released under MIT License. Please refer the LICENSE.txt for more details.
Loading