爬虫 ProxyError 急!!!

爬虫新手,在使用requests.get()中proxies参数后仍旧报错

这不是最困惑的,最困惑的是同样的代码**在服务器上可以成功使用代理,然而我的电脑就无法使用代理,一旦使用就报错**
**之前我也使用过迅云vpn,不知道和这个有无关系

#更换ip函数
def get_proxies(web):
    while True:
        try:
            r = requests.get(web).text
        except Exception as e:
            print("ip更换过快")
            time.sleep(random.random()*3+3)
            continue
        print(json.loads(r))
        ip = json.loads(r)["data"][0]["ip"]
        port = json.loads(r)["data"][0]["port"]
        proxy = ip + ':' + str(port)
        proxies = {'http':'http://'+proxy,'https':'https://'+proxy}
        print(proxies)
        try:
            test = requests.get("https://httpbin.org/get",proxies = proxies,timeout=10).text
            print(test)
        except Exception as e:
            print('ip不可用')
            time.sleep(random.random() * 3 + 5)
            continue
        test = json.loads(test)
        print('ip为:',test["origin"])
        break
    return proxies

函数本身没有问题
报错:

Traceback (most recent call last):

  File "G:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 667, in urlopen
    self._prepare_proxy(conn)

  File "G:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 930, in _prepare_proxy
    conn.connect()

  File "G:\anaconda\lib\site-packages\urllib3\connection.py", line 316, in connect
    self._tunnel()

  File "G:\anaconda\lib\http\client.py", line 896, in _tunnel
    (version, code, message) = response._read_status()

  File "G:\anaconda\lib\http\client.py", line 264, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")

  File "G:\anaconda\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)

ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "G:\anaconda\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(

  File "G:\anaconda\lib\site-packages\urllib3\connectionpool.py", line 724, in urlopen
    retries = retries.increment(

  File "G:\anaconda\lib\site-packages\urllib3\util\retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))

MaxRetryError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /get (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)))


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "C:\Users\lenovo\Desktop\7500-10000\7500-10000.py", line 80, in get_proxies
    test = requests.get("https://httpbin.org/get",proxies = proxies,timeout=10).text

  File "G:\anaconda\lib\site-packages\requests\api.py", line 76, in get
    return request('get', url, params=params, **kwargs)

  File "G:\anaconda\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)

  File "G:\anaconda\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)

  File "G:\anaconda\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)

  File "G:\anaconda\lib\site-packages\requests\adapters.py", line 510, in send
    raise ProxyError(e, request=request)

ProxyError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /get (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)))

在你的电脑的 internet 选项,连接,代理服务器中设置下这个代理ip,端口,通过浏览器访问,看看是否可以访问。
应该是某种机制阻断了代理服务器和你计算机的连接。