typeError: unsetopt() is not supported for this option
typeError: unsetopt() is not supported for this option
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()
没有 return 任何东西。将选项设置为 None
被解释为试图取消设置该选项,此选项不允许这样做。
您应该去掉函数的参数列表,以便传递对函数的引用。
c.setopt(c.WRITEFUNCTION, x.content_callback)
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()
没有 return 任何东西。将选项设置为 None
被解释为试图取消设置该选项,此选项不允许这样做。
您应该去掉函数的参数列表,以便传递对函数的引用。
c.setopt(c.WRITEFUNCTION, x.content_callback)