【问题标题】:python requests not work with vpn ProxyError('Cannot connect to proxy.',python 请求不适用于 vpn ProxyError(\'无法连接到代理。\',
【发布时间】:2022-12-03 12:06:58
【问题描述】:

我将请求与 vpn 一起使用,但它显示错误

(Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

这是代码

import requests
con = requests.get(url)

我可以使用 vpn 在浏览器中访问 url。我必须使用 vpn 来请求。 使用 Python 3.7.9

【问题讨论】:

    标签: python networking python-requests urllib vpn


    【解决方案1】:

    使用 pyPAC 对我有用...... https://pypac.readthedocs.io/en/latest/

    from pypac import PACSession
    from requests.auth import HTTPProxyAuth
    session = PACSession()
    r = session.get('http://google.com')
    

    您可能需要更新您的 python 版本或使用与您的 python 版本匹配的旧版本的 pyPAC。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      • 1970-01-01
      • 2017-01-06
      • 2022-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多