A
A
anya_hacker2021-10-26 18:07:13
Python
anya_hacker, 2021-10-26 18:07:13

Why isn't a request sent to all sites?

Good evening.
I want to send a request to the site through the iPv6 proxy and get the response code.
When I send a request to the google.com site, the code 200 is returned.
However, if I send a request to the site https://2ip.ru/ or to the site https://steamcommunity.com/market/ , then an error occurs:

Traceback (most recent call last):
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 805, in _prepare_proxy
    conn.connect()
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 308, in connect
    self._tunnel()
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 907, in _tunnel
    raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
OSError: Tunnel connection failed: 502 Bad Gateway

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 637, in urlopen
    retries = retries.increment(method, url, error=e, _pool=self,
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.steamcommunity.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 Bad Gateway')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ilyam\PycharmProjects\steam orders bot\parse_id.py", line 65, in <module>
    r = requests.get(f"https://www.steamcommunity.com", proxies=proxies)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\ilyam\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 510, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.steamcommunity.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 Bad Gateway')))


The code:
import requests

proxies = {
    'http': 'http://oOAQ6o:[email protected]:4002',
    'https': 'https://oOAQ6o:[email protected]:4002'
}

r = requests.get(f"https://www.google.com", proxies=proxies)
print(r.status_code)  # 200

url = 'https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Elite%20Build%20%28Field-Tested%29/render/?query=&start=0&count=100&country=RU&language=english&currency=5'

r = requests.get(url, proxies=proxies)
print(r.status_code)  # error
print(r.json())


Why is the request successfully sent to the google.com page, but not to the steamcommunity.com page? How can this problem be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question