我正在尝试使用以下代码从站点获取图像:
image="http://the.site.com/view/ashx/Handler.ashx?Command=Avatar&TC=TQB"
curlobj = pycurl.Curl()
curlobj.setopt(pycurl.COOKIEFILE, '')
curlobj.setopt(pycurl.CONNECTTIMEOUT, 30)
curlobj.setopt(pycurl.TIMEOUT, 30)
curlobj.setopt(pycurl.FAILONERROR, True)
curlobj.setopt(pycurl.FOLLOWLOCATION, 1)
curlobj.setopt(pycurl.MAXREDIRS, 5)
imgf = open("logo.jpg", "wb")
curlobj.setopt(pycurl.URL, image)
curlobj.setopt(pycurl.WRITEDATA, imgf)
curlobj.perform()
imgf.close()
curlobj.close()
但它给出了:
python2`.6: src/pycurl.c:272: get_thread_state: Assertion `self->ob_type == p_Curl_Type' failed.`
问题是什么?
谢谢