【发布时间】:2018-10-09 16:54:06
【问题描述】:
我正在尝试使用 python 中的请求来抓取网站。
url = "https://stackoverflow.com/questions/23013220/max-retries-exceeded-with-url"
# set the headers like we are a browser,
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}
# download the homepage
s = requests.Session()
s.trust_env = False
response = s.get(url, headers=headers )
当我使用我的个人 wifi 时,这一切正常。但是,当我连接到我公司的 VPN 时,我收到以下错误。
ConnectionError: HTTPSConnectionPool(host='stackoverflow.com', port=443): 最大重试次数超出了 url: /questions/23013220/max-retries-exceeded-with-url (由 NewConnectionError(': 无法建立新连接:[WinError 10061] 无法建立连接,因为目标机器主动拒绝它',))
现在,我需要它来通过我公司的 VPN 工作,因为我需要访问一个只能在该 VPN 上工作的网站。如何解决?
【问题讨论】:
标签: python python-requests anaconda