Пример #1
0
 /**
  * Process the result by execution all actions.
  *
  * @param String $url
  * @param String $data
  */
 public function processActions($url, $data)
 {
     $hash = $this->client->createHashFromUrl($url);
     $result = new Result($hash, $url, $data);
     foreach ($this->actions as $action) {
         $result = $action->execute($result);
     }
     unset($result);
 }
Пример #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // set up client
     $client = new HttpClient($input->getArgument('url'));
     if ($input->getOption('user')) {
         $client->setAuth($input->getOption('user'), $input->getOption('password'));
     }
     // set up crawler
     $crawler = new Crawler($client);
     $this->addFilters($input, $crawler);
     $this->addActions($input, $crawler);
     $depth = (int) $input->getOption('depth');
     $links = $crawler->go($depth);
     if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
         $output->writeln('---------------------------------------------');
         foreach ($links as $hash => $link) {
             $output->writeln(sprintf('Found <info>%s</info>', $link));
         }
         $output->writeln('---------------------------------------------');
     }
     $output->writeln(sprintf('Links found <info>%s</info> (depth: %d)', count($links), $depth));
 }
Пример #3
0
 public function testConvertsToFullyQualifiedUrl()
 {
     $client = new HttpClient('http://google.com/');
     $this->assertEquals($client->convertToAbsoluteUrl('http://google.com/test'), $client->convertToAbsoluteUrl('/test'));
 }