问题描述
class ContentCallback:
def __init__(self):
self.contents = ''
def content_callback(self,buf):
self.contents = self.contents + buf
def exploitdb_search(name):
if len(name) != 0:
query = str(name) + ' ' + 'site:https://www.exploit-db.com/'
for data in search(query,num_results=1):
if "https://www.exploit-db.com/exploits" in data:
x = ContentCallback()
c = pycurl.Curl()
c.setopt(c.URL,'{}'.format(data))
c.setopt(c.WRITEFUNCTION,x.content_callback(data))
c.perform()
c.close()
print(t.content)
解决方法
c.WRITEFUNCTION
选项的值应该是一个函数。您正在传递调用函数的结果,即 None
,因为 content_callback()
不返回任何内容。将选项设置为 None
被解释为试图取消设置该选项,这在此选项中是不允许的。
您应该去掉函数的参数列表,以便传递对函数的引用。
c.setopt(c.WRITEFUNCTION,x.content_callback)