1 把scrapy得到的数据传给下一个函数,传递的数据不是url
2
def parse(self, response):
soup = BeautifulSoup(response.body,'lxml')
item = {}
item['stock'] = [i.string.split(':')[0] for i in soup.find_all('a', class_='fxx_wb')]
item['source'] = [i.string for i in soup.find_all('td', style='padding-left:5px')[0::4]
def handler(self):
do something with item
3 自己的想法是把item这个变量传给handler这个函数,看了一下资料 yield scrapy.Request(url, callback=self.handler) 传递url参数并且将访问URL后的response的值传递给回调函数的。请问有没有直接将这个变量传递给下一个回调函数的方法?变量类型是字典或者列表的,不是URL类型
你看文档没有看全,答案很简单,就是用
response.meta
,具体可以参考下面的代码或者直接看文档调试(Debugging)Spiders