[Python] Using Apify Proxy With Playwright

Discussão em 'Python' iniciado por Stack, Fevereiro 20, 2025.

  1. Stack

    Stack Membro Participativo

    So , i Trying To use Playwright Python Script headless With Apify trial Proxy inAnd Run it in Apify Console.

    I always Get different Error When Trying To use thire proxies Nx_proxy error......etc

    I know that they don't allow the use of thire trial proxy outside apify.

    Can someone give the right code to use thire proxy with Playwright in thire console....

    I tried



    from playwright.sync_api import sync_playwright



    # Set your proxy server and authentication credentials

    proxy_server = 'your_proxy_server_address'

    proxy_username = 'your_proxy_username'

    proxy_password = 'your_proxy_password'



    with sync_playwright() as p:

    browser = p.chromium.launch(headless=True)

    page = browser.new_page()



    # Configure proxy settings

    await page.context.set_http_proxy({

    'server': proxy_server,

    'username': proxy_username,

    'password': proxy_password

    })



    # Navigate to a URL that requires proxy authentication

    await page.goto('https://example.com')



    # Continue with your scraping or automation tasks

    # ...



    await browser.close()

    Continue reading...

Compartilhe esta Página