当前位置: 首页>>代码示例>>Python>>正文


Python FronteraScheduler.enqueue_request方法代码示例

本文整理汇总了Python中frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler.enqueue_request方法的典型用法代码示例。如果您正苦于以下问题:Python FronteraScheduler.enqueue_request方法的具体用法?Python FronteraScheduler.enqueue_request怎么用?Python FronteraScheduler.enqueue_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler的用法示例。


在下文中一共展示了FronteraScheduler.enqueue_request方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_redirect_disabled_enqueue_requests

# 需要导入模块: from frontera.contrib.scrapy.schedulers.frontier import FronteraScheduler [as 别名]
# 或者: from frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler import enqueue_request [as 别名]
 def test_redirect_disabled_enqueue_requests(self):
     settings = Settings()
     settings['REDIRECT_ENABLED'] = False
     crawler = FakeCrawler(settings)
     fs = FronteraScheduler(crawler, manager=FakeFrontierManager)
     fs.open(Spider)
     assert fs.enqueue_request(rr1) is False
     assert fs.enqueue_request(rr2) is False
     assert fs.enqueue_request(rr3) is False
开发者ID:scrapinghub,项目名称:frontera,代码行数:11,代码来源:test_frontera_scheduler.py

示例2: test_enqueue_requests

# 需要导入模块: from frontera.contrib.scrapy.schedulers.frontier import FronteraScheduler [as 别名]
# 或者: from frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler import enqueue_request [as 别名]
 def test_enqueue_requests(self):
     crawler = FakeCrawler()
     fs = FronteraScheduler(crawler, manager=FakeFrontierManager)
     fs.open(Spider)
     assert fs.enqueue_request(r1) is True
     assert fs.enqueue_request(r2) is True
     assert fs.enqueue_request(r3) is True
     assert set(seed.url for seed in fs.frontier.manager.seeds) == set([r1.url, r2.url, r3.url])
     assert all([isinstance(seed, FRequest) for seed in fs.frontier.manager.seeds])
     assert fs.stats_manager.stats.get_value('frontera/seeds_count') == 3
开发者ID:RaoUmer,项目名称:frontera,代码行数:12,代码来源:test_frontera_scheduler.py

示例3: test_redirect_enabled_enqueue_requests

# 需要导入模块: from frontera.contrib.scrapy.schedulers.frontier import FronteraScheduler [as 别名]
# 或者: from frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler import enqueue_request [as 别名]
 def test_redirect_enabled_enqueue_requests(self):
     settings = Settings()
     settings['REDIRECT_ENABLED'] = True
     crawler = FakeCrawler(settings)
     fs = FronteraScheduler(crawler, manager=FakeFrontierManager)
     fs.open(Spider)
     assert fs.enqueue_request(rr1) is True
     assert fs.enqueue_request(rr2) is True
     assert fs.enqueue_request(rr3) is True
     assert set([request.url for request in fs._pending_requests]) == set([rr1.url, rr2.url, rr3.url])
开发者ID:scrapinghub,项目名称:frontera,代码行数:12,代码来源:test_frontera_scheduler.py

示例4: test_redirect_disabled_enqueue_requests

# 需要导入模块: from frontera.contrib.scrapy.schedulers.frontier import FronteraScheduler [as 别名]
# 或者: from frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler import enqueue_request [as 别名]
 def test_redirect_disabled_enqueue_requests(self):
     settings = Settings()
     settings['REDIRECT_ENABLED'] = False
     crawler = FakeCrawler(settings)
     fs = FronteraScheduler(crawler, manager=FakeFrontierManager)
     fs.open(Spider)
     assert fs.enqueue_request(rr1) is False
     assert fs.enqueue_request(rr2) is False
     assert fs.enqueue_request(rr3) is True
     assert isinstance(fs.frontier.manager.seeds[0], FRequest)
     assert len(fs.frontier.manager.seeds) == 1
     assert fs.frontier.manager.seeds[0].url == rr3.url
     assert fs.stats_manager.stats.get_value('frontera/seeds_count') == 1
开发者ID:RaoUmer,项目名称:frontera,代码行数:15,代码来源:test_frontera_scheduler.py

示例5: test_redirect_enabled_enqueue_requests

# 需要导入模块: from frontera.contrib.scrapy.schedulers.frontier import FronteraScheduler [as 别名]
# 或者: from frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler import enqueue_request [as 别名]
 def test_redirect_enabled_enqueue_requests(self):
     settings = Settings()
     settings['REDIRECT_ENABLED'] = True
     crawler = FakeCrawler(settings)
     fs = FronteraScheduler(crawler, manager=FakeFrontierManager)
     fs.open(Spider)
     assert fs.enqueue_request(rr1) is True
     assert fs.enqueue_request(rr2) is True
     assert fs.enqueue_request(rr3) is True
     assert len(fs.frontier.manager.seeds) == 1
     assert isinstance(fs.frontier.manager.seeds[0], FRequest)
     assert fs.frontier.manager.seeds[0].url == rr3.url
     assert set([request.url for request in fs._pending_requests]) == set([rr1.url, rr2.url])
     assert all([isinstance(request, Request) for request in fs._pending_requests])
     assert fs.stats_manager.stats.get_value('frontera/seeds_count') == 1
     assert fs.stats_manager.stats.get_value('frontera/redirected_requests_count') == 2
开发者ID:RaoUmer,项目名称:frontera,代码行数:18,代码来源:test_frontera_scheduler.py


注:本文中的frontera.contrib.scrapy.schedulers.frontier.FronteraScheduler.enqueue_request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。