Requests.Get在一台服务器上失败但在另一台服务器上运行

时间:2016-09-06 21:27:09

标签: python python-2.7 amazon-web-services python-requests

我有以下Python 2.7代码:

import requests
from urllib3 import Retry

s = requests.Session()

http_retries = Retry(3)
https_retries = Retry(3)

http = requests.adapters.HTTPAdapter(max_retries=http_retries)
https = requests.adapters.HTTPAdapter(max_retries=https_retries)

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36',}

s.mount('http://', http)
s.mount('https://', https)

response = s.get(URL, headers=headers, timeout=10)

我一直在

  

无法建立新连接:[Errno 101]网络无法访问'

当我从亚马逊AWS实例运行脚本但在另一个网络上运行时,它运行正常。

知道为什么

0 个答案:

没有答案