官方手册里这样写的
def on_start(self):
self.crawl('http://www.example.org/', callback=self.callback,
save={'a': 123})
def callback(self, response):
return response.save['a']
我是这样写的。
@every(minutes=24 * 60)
def on_start(self):
self.crawl('http://baidu.com', callback=self.index_page,
save={'a': 123 })
@config(age=10 * 24 * 60 * 60)
def index_page(self, response):
print response.save['a']
for each in response.doc('a[href^="http"]').items():
self.crawl(each.attr.href, callback=self.detail_page)
报错
[E 150623 17:50:22 basehandler:193] 'NoneType' object has no attribute 'getitem'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pyspider/libs/base_handler.py", line 186, in run_task
result = self._run_task(task, response)
File "/usr/local/lib/python2.7/dist-packages/pyspider/libs/base_handler.py", line 166, in _run_task
return self._run_func(function, response, task)
File "/usr/local/lib/python2.7/dist-packages/pyspider/libs/base_handler.py", line 148, in _run_func
return function(*arguments[:len(args) - 1])
File "<taobao>", line 20, in index_page
TypeError: 'NoneType' object has no attribute 'getitem_'
这是为何 是我做错了什么?