python scrapy从函数发送数据到函数

时间:2014-01-15 19:24:42

标签: python python-2.7 scrapy

我有这个

def parse(self, response):
    sel = Selector(response)
    sites = sel.xpath('myXpath')
    for site in sites:
        Date = site.css('p[class=date]::text').extract()
        yield Request(Link, callback = self.parseOneCar)

def parseOneCar(self, response):
    sel = Selector(response)
    Do somethings

我想将Date发送给第二个蜘蛛。

怎么样?

1 个答案:

答案 0 :(得分:2)

def parse(self, response):
    ...
    yield Request(Link, 
                  meta={'date': Date},
                  callback = self.parseOneCar)

def parseOneCar(self, response):
    ...
    Date = response.meta['date']

了解更多信息see the docs