So now, we're ready to finish the heart of our crawler. Let
me put the last statement in, so you know there's nothing else missing
and you'll be able to test this. And the last thing we
want to do is return the result in crawled. When we finished the
while loop, we're ready to return crawled, which is the list of
pages we found. What we have left to do is to figure out
what we do to crawl each page. This is going to be a
pretty tough quiz, I think you'll need at least two lines of code.
If you think about using all the procedures that you've
learned about and the ones that you've defined in earlier quizzes,
you shouldn't need more than two lines. And the two
things that you need to do are update the value of
to crawl to reflect all the new links that are
found on page And update the value of crawled, to keep
track of the pages that have been crawled. See if
you can figure out how to finish the crawl web procedure.
クローラの核心が完成しつつあります
最後のステートメントです
何も欠けていないことが分かります
これをテストします
最後に行う必要のあることは
crawledの結果を返すことです
whileループを終了するとcrawledを返します
これは見つけたページのリストです
あとは各ページをクロールするために
行うことを考えます
これは非常に難しいですね
少なくとも2行のコードが必要でしょう
今まで学んで小テストで定義してきた
すべての関数を活用すれば
3行以上にならないでしょう
行うべきことはページ上で見つかった新たなリンクを
すべて反映させるために
tocrawlの値をアップデートすることと
クロールされているページを把握するため
crawledの値をアップデートすることです
crawl_web関数を
どのように完成させるのか考えてください