本文整理汇总了Python中scrapy.http.request.Request.meta["num"]方法的典型用法代码示例。如果您正苦于以下问题:Python Request.meta["num"]方法的具体用法?Python Request.meta["num"]怎么用?Python Request.meta["num"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.http.request.Request
的用法示例。
在下文中一共展示了Request.meta["num"]方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_list_detail
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["num"] [as 别名]
def parse_list_detail(self, response):
hxs = HtmlXPathSelector(response)
shops = hxs.select('//li[@class="shopname"]/a/@href').extract()
for shop in shops:
url = base_url + shop
request = Request(url, callback=self.parse_detail)
request.meta["num"] = response.request.meta["num"]
request.meta["need_js"] = True
yield request
示例2: parse_page
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["num"] [as 别名]
def parse_page(self, response):
hxs = HtmlXPathSelector(response)
max_num = 0
pages = hxs.select('//a[@class="PageLink"]/text()').extract()
for page in pages:
page = int(page)
if page > max_num:
max_num = page
# TODO list it
for i in range(1, max_num + 1):
url = response.request.url + "p%s" % str(i)
request = Request(url, callback=self.parse_list_detail)
request.meta["num"] = response.request.meta["num"]
print("yield request url %s" % url)
yield request
示例3: parse
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["num"] [as 别名]
def parse(self, response):
for i in range(START, END):
request = Request(url=SPIDER_URLS[i], callback=self.parse_page)
request.meta["num"] = str(i)
yield request