public function handle()
 {
     Crawler::create()->setCrawlProfile($this->getProfile())->setCrawlObserver($this->getReporter())->startCrawling($this->getUrlToBeCrawled());
     $this->info('All done!');
 }
Exemplo n.º 2
-5
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $baseUrl = $input->getArgument('url');
     $output->writeln("Start scanning {$baseUrl}");
     $output->writeln('');
     $crawlLogger = new CrawlLogger($output);
     if ($input->getOption('output')) {
         $outputFile = $input->getOption('output');
         if (file_exists($outputFile)) {
             $helper = $this->getHelper('question');
             $question = new ConfirmationQuestion("The output file `{$outputFile}` already exists. Overwrite it? (y/n)", false);
             if (!$helper->ask($input, $output, $question)) {
                 $output->writeln('Aborting...');
                 return 0;
             }
         }
         $crawlLogger->setOutputFile($input->getOption('output'));
     }
     Crawler::create()->setConcurrency($input->getOption('concurrency'))->setCrawlObserver($crawlLogger)->startCrawling($baseUrl);
     return 0;
 }
Exemplo n.º 3
-6
 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $baseUrl = $input->getArgument('url');
     $output->writeln("Start scanning {$baseUrl}");
     $output->writeln('');
     Crawler::create()->setCrawlObserver(new CrawlLogger($output))->startCrawling($baseUrl);
     return 0;
 }