1

I am trying to write an automation script that uses a proxy. I initially tried using Selenium, but it doesn't offer an easy way to authenticate the proxy since Selenium can't interact with the authentication popup. I then switched to Playwright, where it appears that proxy authentication is supported as per the documentation here.

Below is my code snippet:

# Relevant code for initializing proxy and launching browser
proxy = {
    "server": f"http://{proxy_info['host']}:{proxy_info['port']}",
    "username": proxy_info['username'],
    "password": proxy_info['password']
}

# Initialize Playwright and launch browser
with sync_playwright() as p:
    browser = p.chromium.launch(proxy=proxy)
    page = browser.new_page()
    page.goto("https://www.google.com", timeout=60000)
    # Rest of the code

When I run the script, I get the following error:

playwright._impl._api_types.Error: net::ERR_TUNNEL_CONNECTION_FAILED at https://www.google.com/

The script works fine when I run it without the proxy settings. I am new to both proxies and Playwright, so I'm not sure what the issue is or how to fix it. Are there any better ways to handle browser automation with proxies?

1 Answer 1

-2

Try switching your browser to firefox, had a similar issue and it helped

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.