-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Hello there, thanks for this great project.
I'm having trouble making requests though a proxy. Consider the following snippet:
import asyncio
from playwright import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
proxy={
"server": "PROXY_URL",
"username": "PROXY_APIKEY",
"password": "",
},
)
context = await browser.newContext(ignoreHTTPSErrors=True)
page = await context.newPage()
await page.goto("https://httpbin.org/ip")
print(await page.content())
await page.screenshot(path="ip_address.png")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())
If I run it, I get:
$ DEBUG=pw:api python proxy.py
pw:api navigating to "https://httpbin.org/ip", waiting until "load" +0ms
pw:api navigated to "https://httpbin.org/ip" +1s
pw:api "load" event fired +7ms
pw:api "domcontentloaded" event fired +8ms
<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Internal Server Error</pre></body></html>
I can confirm the proxy URL and credentials are correct with cURL (the resulting IP address is not my own, as expected):
$ curl --insecure --proxy $PROXY_URL --proxy-user $PROXY_APIKEY: https://httpbin.org/ip
{
"origin": "xxx.xxx.xxx.xxx"
}
Could this be caused by the fact that the proxy server expects an empty password and Playwright sends some default value? For the record, I'm using Python 3.8.2 and Playwright 0.171.1 on GNU/Linux.
Looking forward to your answers, thanks again for the hard work.