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


Python FormRequest.meta["first_url"]方法代碼示例

本文整理匯總了Python中scrapy.FormRequest.meta["first_url"]方法的典型用法代碼示例。如果您正苦於以下問題:Python FormRequest.meta["first_url"]方法的具體用法?Python FormRequest.meta["first_url"]怎麽用?Python FormRequest.meta["first_url"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scrapy.FormRequest的用法示例。


在下文中一共展示了FormRequest.meta["first_url"]方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse

# 需要導入模塊: from scrapy import FormRequest [as 別名]
# 或者: from scrapy.FormRequest import meta["first_url"] [as 別名]
 def parse(self, response):
     url  = response.url
     if "research" in url:
         categories = response.xpath(".//*[@class='catec']")
         for i in xrange(len(categories)-1):
             large_categories = categories[i].xpath(".//*[@class='fl']")
             large_category_name = clean_text(large_categories.xpath(".//text()").extract()[0].strip())
             mid_categories = categories[i].xpath(".//span")
             for mid_category in mid_categories:
                 mid_category_name = clean_text(mid_category.xpath(".//text()").extract()[0].strip())
                 page_url = mid_category.xpath(".//@href").extract()[0]
                 request = FormRequest(page_url, callback=self._parse_page_research, dont_filter=True)
                 request.meta["large_category"] = large_category_name
                 request.meta["mid_category"] = mid_category_name
                 request.meta["first_url"] = page_url
                 yield request
     elif "free" in url:
         large_categories = response.xpath(".//*[@class='tul2']//h2//a")
         for i in xrange(len(large_categories)):
             large_category_name = clean_text(large_categories[i].xpath(".//text()").extract()[0].strip())
             page_url = large_categories[i].xpath("./@href").extract()[0]
             request = FormRequest(page_url, callback=self._parse_page_free, dont_filter=True)
             request.meta["large_category"] = large_category_name
             request.meta["first_url"] = page_url
             yield request
開發者ID:hanwei2008,項目名稱:crawl,代碼行數:27,代碼來源:IndustryReportSpider51report.py

示例2: parse_middle_category

# 需要導入模塊: from scrapy import FormRequest [as 別名]
# 或者: from scrapy.FormRequest import meta["first_url"] [as 別名]
 def parse_middle_category(self, response):
     mid_categories = response.xpath(".//*[@class='report2']//h2//a")
     for mid_category in mid_categories:
         mid_category_name = clean_text(mid_category.xpath("./text()").extract()[0].strip())
         page_url = mid_category.xpath("./@href").extract()[0]
         url = urljoin(self.base_url, page_url)
         request = FormRequest(url, callback=self._parse_item, dont_filter=True)
         request.meta["large_category"] = response.meta["large_category"]
         request.meta["mid_category"] = mid_category_name
         request.meta["first_url"] = url
         yield request
開發者ID:hanwei2008,項目名稱:crawl,代碼行數:13,代碼來源:IndustryReportSpiderOcn.py


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