I want to set a custom parameter in my request so that I can get it when I process it in parse_item. This is my code:
def start_requests(self):
yield Request("site_url", meta={'test_meta_key': 'test_meta_value'})
def parse_item(self, response):
print response.meta
parse_item will be called according to the following rules:
self.rules = (
Rule(SgmlLinkExtractor(deny=tuple(self.deny_keywords), allow=tuple(self.client_keywords)), callback='parse_item'),
Rule(SgmlLinkExtractor(deny=tuple(self.deny_keywords), allow=('', ))),
)
According to scrapy doc :
The Response.meta attribute propagates along redirection directions and retries, so you will get the original Request.meta sent by your spider.
But I do not see the usual meta in parse_item. Anyway, to fix it? Is the metaright way?
AliBZ source
share