使用GrabLib(使用PyCurl/LibCurl发出请求)发送请求时,我一直收到超时错误。但是,在使用请求模块时,requests.get方法连接到第三方网站时没有问题。在Windows 10上使用工作网络连接进行PyCurl定时
这里是使用请求和pycurl我的示例代码:
import pycurl
import requests
r = requests.get('http://www.google.com')
print r
c = pycurl.Curl()
c.setopt(pycurl.TIMEOUT_MS, 3000)
c.setopt(pycurl.URL, 'http://www.google.com/')
c.perform()
这里是代码的输出:
<Response [200]>
Traceback (most recent call last):
File "C:/Users/redacted/test2.py", line 10, in <module>
print c.perform()
pycurl.error: (28, 'Resolving timed out after 3000 milliseconds')
有人可以让我知道为什么这可能是这样吗?我在这里陷入死胡同。
它为我工作。也许你的Curl安装有什么问题? – Feneric