Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #346: spider does not process initial_urls #347

Merged
merged 1 commit into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grab/spider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ def run(self):
self.prepare()
if self.task_queue is None:
self.setup_queue()
self.process_initial_urls()
services = [
self.task_dispatcher,
self.task_generator_service,
Expand Down
14 changes: 14 additions & 0 deletions tests/spider_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,17 @@ def task_generator(self):
bot.add_task(task)
bot.run()
self.assertEqual(1, bot.stat.counters['foo'])

def test_initial_urls(self):
url = self.server.get_url()

class TestSpider(Spider):
initial_urls = [url]

def task_initial(self, unused_grab, unused_task):
self.stat.inc('foo', 1)

bot = build_spider(TestSpider)
bot.run()

self.assertEqual(1, bot.stat.counters['foo'])