当前位置: 首页>>代码示例>>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;未经允许,请勿转载。