Slide 14
Slide 14 text
New requirements: Log if verbose mode is enabled
class LinkCrawler
{
public function crawl($url)
{
if ($this->verbose) {
$this->logger(sprintf('Crawling "%s".', $url));
}
if (0 === strpos($url, 'http')) {
$content = $this->browser->get(
$url, ['content-type' => 'application/json']
);
} else {
$content = file_get_contents($url);
}
$links = $this->linkExtractor->extract($content);
$this->linkRepository->store($links);
}
}