Ejemplo n.º 1
0
async def main():
    try:
        # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
        kameleo_port = 5050

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

        # Search Chrome Base Profiles
        base_profiles = client.search_base_profiles(device_type='desktop',
                                                    browser_product='chrome')

        # Create a new profile with recommended settings
        # Choose one of the Base Profiles
        create_profile_request = BuilderForCreateProfile \
            .for_base_profile(base_profiles[0].id) \
            .set_recommended_defaults() \
            .build()
        profile = client.create_profile(body=create_profile_request)

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

        # Connect to the browser with Puppeteer through CDP
        browser_ws_endpoint = f'ws://localhost:{kameleo_port}/puppeteer/{profile.id}'
        browser = await pyppeteer.launcher.connect(
            browserWSEndpoint=browser_ws_endpoint, defaultViewport=False)
        page = await browser.newPage()

        # Use any Puppeteer command to drive the browser
        # and enjoy full protection from bot detection products
        await page.goto('https://google.com')
        await page.click('div[aria-modal="true"][tabindex="0"] button + button'
                         )
        await page.click('[name=q')
        await page.keyboard.type('Kameleo')
        await page.keyboard.press('Enter')

        # Wait for 5 seconds
        time.sleep(5)

        # Stop the browser by stopping the Kameleo profile
        client.stop_profile(profile.id)
    except ProblemResponseException as e:
        raise Exception([str(e), json.dumps(e.error.error)])
Ejemplo n.º 2
0
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.models.server_py3 import Server
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
import json

try:
    # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
    kameleo_port = 5050

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

    # Create test proxy request object
    request = {
        'value':
        'http',
        'extra':
        Server(host='<host>', port=1080, id='<userId>', secret='<userSecret>')
    }

    # Search Chrome Base Profiles
    test_proxy_response = client.test_proxy(body=request)
    print('Result: ' + str(test_proxy_response))

except ProblemResponseException as e:
    raise Exception([str(e), json.dumps(e.error.error)])
Ejemplo n.º 3
0
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
from kameleo.local_api_client.models.cookie_request_py3 import CookieRequest
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
from selenium import webdriver
import time
import json

try:
    # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
    kameleo_port = 5050

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

    # Search Chrome Base Profiles
    base_profiles = client.search_base_profiles(device_type='desktop',
                                                browser_product='firefox')

    # Create a new profile with recommended settings for browser fingerprinting protection
    # Choose one of the Firefox BaseProfiles
    create_profile_request = BuilderForCreateProfile \
        .for_base_profile(base_profiles[0].id) \
        .set_recommended_defaults() \
        .build()
    profile = client.create_profile(body=create_profile_request)

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

    # Connect to the running browser instance using WebDriver
    options = webdriver.ChromeOptions()
Ejemplo n.º 4
0
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
from selenium import webdriver
import time
import json


try:
    # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
    kameleo_port = 5050

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

    # Search Chrome Base Profiles
    base_profiles = client.search_base_profiles(
        device_type='desktop',
        browser_product='chrome'
    )

    # Create a new profile with recommended settings
    # Choose one of the Base Profiles
    create_profile_request = BuilderForCreateProfile \
        .for_base_profile(base_profiles[0].id) \
        .set_recommended_defaults() \
        .build()
    profile = client.create_profile(body=create_profile_request)

    # Start the browser profile
    client.start_profile(profile.id)
Ejemplo n.º 5
0
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
from kameleo.local_api_client.models.web_driver_settings_py3 import WebDriverSettings
from kameleo.local_api_client.models.preference_py3 import Preference
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
import time
import json


try:
    # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
    kameleo_port = 5050

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

    # Search Chrome Base Profiles
    base_profiles = client.search_base_profiles(
        device_type='desktop',
        browser_product='chrome'
    )

    # Create a new profile with recommended settings for browser fingerprinting protection
    # Choose one of the Chrome BaseProfiles
    create_profile_request = BuilderForCreateProfile \
        .for_base_profile(base_profiles[0].id) \
        .set_recommended_defaults() \
        .build()
    profile = client.create_profile(body=create_profile_request)

    # Provide additional settings for the web driver when starting the browser
    client.start_profile_with_web_driver_settings(profile.id, WebDriverSettings(
Ejemplo n.º 6
0
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
from kameleo.local_api_client.models.save_profile_request_py3 import SaveProfileRequest
from kameleo.local_api_client.models.load_profile_request_py3 import LoadProfileRequest
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
import time
import os
import json

try:
    # This is the port Kameleo.CLI is listening on. Default value is 5050, but can be overridden in appsettings.json file
    kameleo_port = 5050

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

    # Search Chrome Base Profiles
    base_profiles = client.search_base_profiles(device_type='desktop',
                                                browser_product='chrome')

    # Create a new profile with recommended settings for browser fingerprinting protection
    # Choose one of the Chrome BaseProfiles
    create_profile_request = BuilderForCreateProfile \
        .for_base_profile(base_profiles[0].id) \
        .set_recommended_defaults() \
        .build()
    profile = client.create_profile(body=create_profile_request)

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

    # Wait for 5 seconds