Ready for a free 2 GB trial?

Book a call with one of our Data Nerds to unlock a super-sized free trial.

START TRIAL

如何向 Kameleo 添加代理

Kameleo API 集成

了解如何将大规模代理与 Kameleo 防检测浏览器集成,在自动执行网络任务的同时管理多个账户并保持匿名性。

Kameleo 是什么?

Kameleo 是一款反检测浏览器,可帮助你绕过Cloudflare、DataDome和PerimeterX等反机器人系统。与可以通过WebDriver自动化框架或CDP泄漏检测到的传统无头浏览器不同,Kameleo可确保您的自动化浏览器保持不可检测状态,即使通过Selenium、Puppeteer或Playwright等自动化工具进行控制,也能显示为真正的用户浏览器。

主要特征

  • 逼真的浏览器指纹屏蔽
  • 操控画布和 WebGL 以避免被发现
  • 无限的浏览器配置文件
  • 用于移动配置文件仿真的移动应用程序。
  • 自定义安全浏览器: Chroma 丛林狐狸
  • 本地 API 可实现顺畅自动化
  • 多平台支持:Windows 和 macOS
  • 没有请求速率限制

第 1 步:安装 Kameleo

  1. 在以下地址创建 Kameleo 账户 他们的注册页面
  2. 选择并购买合适的计划
  3. 从下载安装程序 Kameleo 的下载页面
  4. 关注 安装指南

第 2 步:设置海量代理

大规模代理通过提供来自全球不同地点的100%符合道德标准的住宅IP来改善Kameleo的功能。巨大 住宅代理 报价:

  • 99.84% 成功率
  • 响应时间 <0.8 秒
  • 覆盖全球 195 多个地点

大规模代理设置步骤

  1. 参观 joinmassive.com 并注册一个计划。
  2. 注册后,前往 代理身份验证 在你的选项卡中 仪表板 检索您的代理凭证(用户名和密码)

有关详细配置选项,请参阅 海量文档

第 3 步:启动 Kameleo.cli

Windows:

cd C:\Users\<YOUR_USERNAME>\AppData\Local\Programs\Kameleo
Kameleo.CLI.exe email=<YOUR_EMAIL> password=<YOUR_PASSWORD>

macOS:

cd /Applications/Kameleo.app/Contents/Resources/CLI/
./Kameleo.CLI email=<YOUR_EMAIL> password=<YOUR_PASSWORD>

将<YOUR_EMAIL>和替换<YOUR_PASSWORD>为您的 Kameleo 凭证。

CLI 将在以下位置启动本地 REST API 服务器 http://localhost:5050 如下图所示:

第 4 步:通过 Python 连接到 Kameleo

安装 Kameleo 客户端库:

pip install kameleo.local-api-client

初始化 Kameleo 客户端:

from kameleo.local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.models import CreateProfileRequest, ProxyChoice, Server
import time
import os

kameleo_port = os.getenv('KAMELEO_PORT', '5050')

第 5 步:使用 Massive Proxy 创建浏览器配置文件

5.1 查找基本浏览器配置文件

Kameleo 用途 基本配置文件 (真实的浏览器指纹)来创建虚拟浏览器配置文件。您可以根据自己的要求筛选这些配置文件。

fingerprints = client.fingerprint.search_fingerprints(
    device_type='desktop',
    browser_product='chrome',
    browser_version='>134',
)

5.2 配置代理设置

使用选定的基本配置文件创建新的浏览器配置文件并将其配置为使用 Massive Proxies。

PROXY_HOST = os.getenv('PROXY_HOST', 'network.joinmassive.com')
PROXY_PORT = int(os.getenv('PROXY_PORT', '65534'))
PROXY_USERNAME = os.getenv('PROXY_USERNAME', '<your_proxy_username>')
PROXY_PASSWORD = os.getenv('PROXY_PASSWORD', '<your_proxy_password>')

create_profile_request = CreateProfileRequest(
    fingerprint_id=fingerprints[0].id,
    name='Massive + Kameleo Profile',
    proxy=ProxyChoice(
        value='http',
        extra=Server(host=PROXY_HOST, port=PROXY_PORT, id=PROXY_USERNAME, secret=PROXY_PASSWORD)
    ))
profile = client.profile.create_profile(create_profile_request)

将 PROXY_USERNAME 和 PROXY_PASSWORD 替换为您的大规模代理凭证。

第 6 步:启动浏览器

使用以下代码启动/停止浏览器配置文件:

# Start the browser profile
client.profile.start_profile(profile.id)

# Wait for 10 seconds
time.sleep(10)

# Stop the browser by stopping the Kameleo profile
client.profile.stop_profile(profile.id)

合并所有代码

以下是使用大规模代理创建和启动浏览器配置文件的完整 Python 脚本:

from kameleo.local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.models import CreateProfileRequest, ProxyChoice, Server
import time
import os

# This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
kameleo_port = os.getenv('KAMELEO_PORT', '5050')

client = KameleoLocalApiClient(
    endpoint=f'http://localhost:{kameleo_port}'
)

PROXY_HOST = os.getenv('PROXY_HOST', 'network.joinmassive.com')
PROXY_PORT = int(os.getenv('PROXY_PORT', '65534'))
PROXY_USERNAME = os.getenv('PROXY_USERNAME', '<your_proxy_username>')
PROXY_PASSWORD = os.getenv('PROXY_PASSWORD', '<your_proxy_password>')

fingerprints = client.fingerprint.search_fingerprints(
    device_type='desktop',
    browser_product='chrome',
    browser_version='>134',
)

create_profile_request = CreateProfileRequest(
    fingerprint_id=fingerprints[0].id,
    name='Massive + Kameleo Profile',
    proxy=ProxyChoice(
        value='http',
        extra=Server(host=PROXY_HOST, port=PROXY_PORT, id=PROXY_USERNAME, secret=PROXY_PASSWORD)
    ))
profile = client.profile.create_profile(create_profile_request)

# Start the browser profile
client.profile.start_profile(profile.id)

# Wait for 10 seconds
time.sleep(10)

# Stop the browser by stopping the Kameleo profile
client.profile.stop_profile(profile.id)

自动化浏览器(剧作家示例)

你可以使用 Selenium、Puppeteer 或 Playwright 等框架来实现浏览器自动化。以下是使用 Playwright 的示例:

from kameleo.local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.models import CreateProfileRequest
from playwright.sync_api import sync_playwright
import time
import os

# This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
kameleo_port = os.getenv('KAMELEO_PORT', '5050')
client = KameleoLocalApiClient(
    endpoint=f'http://localhost:{kameleo_port}'
)

# Search Chrome fingerprints
fingerprints = client.fingerprint.search_fingerprints(
    device_type='desktop',
    browser_product='chrome',
)

# Create a new profile with recommended settings
# Choose one of the fingerprints
create_profile_request = CreateProfileRequest(
    fingerprint_id=fingerprints[0].id,
    name='Kameleo Massive Integration')

profile = client.profile.create_profile(create_profile_request)

# Start the Kameleo profile and connect with Playwright through CDP
browser_ws_endpoint = f'ws://localhost:{kameleo_port}/playwright/{profile.id}'
with sync_playwright() as playwright:
    browser = playwright.chromium.connect_over_cdp(endpoint_url=browser_ws_endpoint)
    context = browser.contexts[0]
    page = context.new_page()
    page.set_viewport_size({"width": 1280, "height": 800})
    
    # Use any Playwright command to drive the browser and enjoy full protection from bot detection products
    page.goto('https://www.joinmassive.com/')
    page.hover("text=Resources")
    page.click("text=Partners")
    page.wait_for_load_state('networkidle')
    page.click("text=Kameleo")

# Wait for 5 seconds
time.sleep(5)

# Stop the browser by stopping the Kameleo profile
client.profile.stop_profile(profile.id)

更多示例,请参阅 Kameleo API 示例

通过 GUI 管理配置文件

您可以使用 Kameleo GUI 管理和监控您的浏览器配置文件。只需登录 Kameleo 应用程序并导航到 概况 部分。

其他资源