本文整理汇总了Python中scrapy.Request.meta['name']方法的典型用法代码示例。如果您正苦于以下问题:Python Request.meta['name']方法的具体用法?Python Request.meta['name']怎么用?Python Request.meta['name']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.Request
的用法示例。
在下文中一共展示了Request.meta['name']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_poetryList
# 需要导入模块: from scrapy import Request [as 别名]
# 或者: from scrapy.Request import meta['name'] [as 别名]
def parse_poetryList(self,response):
poetrys = response.xpath('//div[@class="son2List"]/div/a')
if len(poetrys) > 0:
poetry_url = poetrys[0].xpath('./@href').extract()
if len(poetry_url) >0 :
poetry_url = self.home_url + poetry_url[0]
request = Request(url = poetry_url, callback=self.parse_poetry)
request.meta['name'] = response.meta['name']
request.meta['setUrl'] = response.meta['setUrl']
request.meta['descrip'] = response.meta['descrip']
yield request
示例2: parse_poetry
# 需要导入模块: from scrapy import Request [as 别名]
# 或者: from scrapy.Request import meta['name'] [as 别名]
def parse_poetry(self,response):
poets = response.xpath('//div[@class="son2Title"]/div/a')
if len(poets) > 0:
poet_url = poets[0].xpath('./@href').extract()
if len(poet_url) > 0:
poetpageurl = poet_url[0]
request = Request(url = poetpageurl, callback=self.parse_authorPage)
print poetpageurl
request.meta['name'] = response.meta['name']
request.meta['setUrl'] = response.meta['setUrl']
request.meta['descrip'] = response.meta['descrip']
yield request
示例3: parse_item
# 需要导入模块: from scrapy import Request [as 别名]
# 或者: from scrapy.Request import meta['name'] [as 别名]
def parse_item(self,response):
poet = response.xpath('//div[@class="son2AuthorCont"]')
poet_title = poet.xpath('./div[@class="authorTile"]/strong/text()').extract()
poetryUrls = poet.xpath('./div[@class="authorTile"]/a/@href').extract()
poet_poetrySetUrl = self.home_url
poet_descrip = poet.xpath('./div[@class="authorShow"]//p/text()').extract()
if len(poet_descrip) <=0 :
poet_descrip = poet.xpath('./div[@class="authorShow"]/text()').extract()
if len(poetryUrls) > 0:
poet_poetrySetUrl += poetryUrls[0]
request = Request(url = poet_poetrySetUrl, callback=self.parse_poetryList)
request.meta['name'] = poet_title[0]
request.meta['setUrl'] = poet_poetrySetUrl
request.meta['descrip'] = ("".join(poet_descrip)).strip()
yield request