L
L
lleballex2020-07-15 11:26:38
Python
lleballex, 2020-07-15 11:26:38

How to use proxy with authorization in Python requests?

I'm trying to access a site using a proxy (free for now). But for some reason an error pops up. What am I doing wrong?
Here is the code:

import requests
from requests.auth import HTTPProxyAuth


URL = 'https://www.avito.ru'

PROXY_URLS = {
  'https': '185.168.250.121:8000',
  'http': '185.168.250.121:8000',
}

AUTH = HTTPProxyAuth('H53R8g', 'NHpB4w')


response = requests.get(URL, proxies=PROXY_URLS, auth=AUTH)

But an error pops up:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.avito.ru', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-07-15
@dimonchik2013

cm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question