本文整理汇总了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
示例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
示例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])
示例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
示例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