/** * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $url = $input->getArgument(self::ARGUMENT_URL); $crawler = CrawlerFactory::createCrawler($output); try { $crawler->parse($url); } catch (RequestException $e) { $output->writeln('<fg=red>' . $e->getMessage() . '</>'); } $output->writeln(' '); if (!$crawler->hasErrorUrls()) { $output->writeln('<info>Congrats! No error pages found</info>'); $output->writeln(' '); return; } $errorsFound = $crawler->getErrorUrls(); $output->writeln('<fg=red>' . count($errorsFound) . ' Errors found</>'); foreach ($errorsFound as $url => $error) { $output->writeln($url . ' => ' . $error); } $output->writeln(' '); }
public function test_Client() { $output = new Output(); $crawler = CrawlerFactory::createCrawler($output); $this->assertInstanceOf(Crawler::class, $crawler); }