官方手册里这样写的
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_'
这是为何 是我做错了什么?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.