deedy5/primp

Issue with Proxy (requires unnecessary auth)

Opened this issue · 0 comments

I'm attempting to run this with zyte's rotating proxy as follows:

import primp
zyte_proxy = "http://MY_API_KEY:@api.zyte.com:8011"
client = primp.Client(proxy=zyte_proxy, verify=False)
resp = client.post(url="https://httpbin.org/anything", timeout=10)

and am getting this error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[50], [line 4](vscode-notebook-cell:?execution_count=50&line=4)
      [2](vscode-notebook-cell:?execution_count=50&line=2) zyte_proxy = "[http://553152efe46f4d61b928826aa8147a51:@api.zyte.com:8011](http://553152efe46f4d61b928826aa8147a51@api.zyte.com:8011/)"
      [3](vscode-notebook-cell:?execution_count=50&line=3) client = primp.Client(proxy=zyte_proxy, verify=False, impersonate="chrome_101")
----> [4](vscode-notebook-cell:?execution_count=50&line=4) resp = client.post(url="https://httpbin.org/anything", timeout=10)

RuntimeError: error sending request for url (https://httpbin.org/anything): error trying to connect: proxy authentication required

Caused by:
    0: error trying to connect: proxy authentication required
    1: proxy authentication required

In contrast, the same proxy works just fine using requests:

proxies = {
        scheme: "http://MY_API_KEY:@api.zyte.com:8011"
        for scheme in ("http")
}
import requests

response = requests.get(
    "https://toscrape.com",
    proxies=proxies,
    verify=False,
)
http_response_body: bytes = response.content
print(http_response_body.decode())