本文整理匯總了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