scrapy Request 回調帶參數

yield scrapy.Request(
                     company_href, 
                     dont_filter=True,
                     cookies=cookies_dict,
                     callback=lambda response, company_href =company_href: self.detail_parse(response, company_href),
                     meta = {'company_href':company_href}
                     )

def detail_parse(self,response,company_href):
        url = response.url
        print(response.meta['company_href'])
        print(company_href)

兩種方法。

一、callback函數帶參數

二、放在meta裏面

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章