當前位置: 首頁>>代碼示例>>Python>>正文


Python Request.meta["node"]方法代碼示例

本文整理匯總了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
開發者ID:nbompetsis,項目名稱:ScrapyMonRg,代碼行數:27,代碼來源:myspider.py

示例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
開發者ID:nbompetsis,項目名稱:ScrapyMonRg,代碼行數:16,代碼來源:myspider.py

示例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
開發者ID:nbompetsis,項目名稱:ScrapyMonRg,代碼行數:18,代碼來源:myspider.py


注:本文中的scrapy.http.request.Request.meta["node"]方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。