本文整理汇总了Python中scrapy.http.request.Request.meta["node"]方法的典型用法代码示例。如果您正苦于以下问题:Python Request.meta["node"]方法的具体用法?Python Request.meta["node"]怎么用?Python Request.meta["node"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scrapy.http.request.Request
的用法示例。
在下文中一共展示了Request.meta["node"]方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["node"] [as 别名]
def parse(self, response):
"""First step of Mon/gr parsing."""
try:
# Connect to Beanstalkd server
self.beanstalk = beanstalkc.Connection(host=self.host_beanstalkd, port=11301)
# See all tubes:
self.beanstalk.tubes()
# Switch to the default (tube):
self.beanstalk.use("default")
# self.makedirResults()
self.nodes = json.loads(response.body_as_unicode())
for node in self.nodes:
link_node = self.domain + self.nodes[node]
request = Request(link_node, callback=self.parseDomain)
# Pass metadata to the next wave of parsing
request.meta["node"] = node
yield request
except:
print "Please run the beanstalkc"
return
示例2: parseDomain
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["node"] [as 别名]
def parseDomain(self, response):
"""Second step of Mon/rg parsing (Domains)."""
node = response.meta["node"]
self.domains = json.loads(response.body_as_unicode())
for dom in self.domains:
link_dom = self.domain + self.domains[dom]
request = Request(link_dom, callback=self.parseStatements)
# Pass metadata to the next wave of parsing
request.meta["node"] = node
request.meta["domain"] = dom
yield request
return
示例3: parseStatements
# 需要导入模块: from scrapy.http.request import Request [as 别名]
# 或者: from scrapy.http.request.Request import meta["node"] [as 别名]
def parseStatements(self, response):
"""Third step of Mon/rg parsing (Category)."""
node = response.meta["node"]
dom = response.meta["domain"]
self.statements = json.loads(response.body_as_unicode())
for statement in self.statements:
link_state = self.domain + self.statements[statement]
request = Request(link_state, callback=self.parseNativeObjects)
# Pass metadata to the next wave of parsing
request.meta["node"] = node
request.meta["domain"] = dom
request.meta["statement"] = statement
yield request
return