William Davis
William Davis

Reputation: 1

How to Use Authenticated Socks 5 Proxies (username:password@ip:port) with Playwright in Python?

I'm working on a web automation project using Playwright in Python. My proxy provider recently switched to authenticated proxies in the format username:password@ip:port.

The usual workflow of my program is:

Take the proxy as input before running. Hook to the proxy. Load the page and start automation. However, I can't seem to get authenticated proxies working with Playwright. I have tried the following approaches without success:

Using PySocks. Various libraries and suggestions, including ChatGPT recommendations. Some suggestions like ProxyChains or Proxifier do work but aren't suitable for my use case. I need to:

  1. Run multiple tools with different proxies simultaneously.
  2. Take proxy as input username:password@ip:port and launch a firefox nightly window using this proxy

My Requirements: Use authenticated proxies (username:password@ip:port) directly with Playwright. Avoid using external tools like ProxyChains or Proxifier.

Any help, workarounds, or libraries that can make this work would be greatly appreciated!

What I've tried so far:

  1. Setting the proxy via Playwright's launch method.
  2. Adding authentication headers directly (didn't work for proxies).
  3. External libraries like PySocks, but they didn’t integrate seamlessly with Playwright
  4. Many ChatGPT 4o Suggestions

Upvotes: 0

Views: 194

Answers (1)

greggyNapalm
greggyNapalm

Reputation: 543

Try to use example code from this article https://datascrape.tech/blog/scriptable-and-headless-wb/

There are two code examples, Selenium and Playwrite, that both use proxies. Also, doublecheck that your proxy is working using cURL

Upvotes: 0

Related Questions