我想要再願望清單上做記號,
當有抓到這本書有二手書的時候,立即丟line通知我。
在傳送參數時,加上 meta={"name":value}
def start_requests(self):
source_url = "...."
for keyword in self.db.wishList.find ({},{ "name" :1 , "_id" : 0 ,"quote":1 } ):
self.log(keyword['name'])
#self.log("urlencode::: " + urlparse.quote(keyword['name']))
start_url = source_url + urlparse.quote(keyword['name'])
yield scrapy.Request(start_url,self.parse,meta={"favorite":keyword['quote']})
使用方式,response.meta.get('name')
def parse(self, response):
#le = LinkExtractor(restrict_css='div.panel-default>a.list-group-item')
#指到二手書列表
#self.log("source_url_link is ===" + response.url)
self.log("favorite: "+ response.meta.get('favorite'))
ref.Passing a argument to a callback function
0 意見:
張貼留言