我正在尝试将CURL 的 CURLOPT_MAX_RECV_SPEED_LARGE 选项与 pycurl 库一起使用。这是我的测试代码:
import sys
import pycurl
class Test:
def __init__(self):
self.contents = ''
def body_callback(self, buf):
self.contents = self.contents + buf
print >>sys.stderr, 'Testing', pycurl.version
t = Test()
c = pycurl.Curl()
c.setopt(c.URL, 'http://curl.haxx.se/dev/')
c.setopt(c.WRITEFUNCTION, t.body_callback)
c.setopt(c.CURLOPT_MAX_RECV_SPEED_LARGE, 1024)
c.perform()
c.close()
print t.contents
它会产生错误;似乎没有为此选项定义库常量。
Traceback (most recent call last):
File "/Users/nilayanand/Documents/workspace/photofeed/photofeed-desktop/test/curl.py", line 18, in <module>
c.setopt(c.CURLOPT_MAX_RECV_SPEED_LARGE, 1024)
AttributeError: CURLOPT_MAX_RECV_SPEED_LARGE
如何在 pycurl 中使用 CURLOPT_MAX_RECV_SPEED_LARGE 选项?