コード例 #1
0
 public function onHtmlResponse(CrawlerHtmlResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $crawler = $event->getDomCrawler();
     $nodes = $crawler->filterXPath('descendant-or-self::link[@rel = "stylesheet" and (@href)]');
     $urls = $nodes->extract('href');
     $this->processUris($event, $dispatcher, $urls, 'stylesheet');
 }
コード例 #2
0
 /**
  * Discover link URLS from anchor tags.
  *
  * @param \LastCall\Crawler\Event\CrawlerHtmlResponseEvent            $event
  * @param                                                             $eventName
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
  */
 public function onHtmlResponse(CrawlerHtmlResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $crawler = $event->getDomCrawler();
     $nodes = $crawler->filterXPath('descendant-or-self::a[@href]');
     $urls = array_unique($nodes->extract('href'));
     $this->processUris($event, $dispatcher, $urls, 'link');
 }
コード例 #3
0
 public function onHtmlResponse(CrawlerHtmlResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $crawler = $event->getDomCrawler();
     $nodes = $crawler->filterXPath('descendant-or-self::script[@type = "text/javascript" and (@src)]');
     $urls = $nodes->extract('src');
     $this->processUris($event, $dispatcher, $urls, 'script');
 }
コード例 #4
0
 public function onHtmlResponse(CrawlerHtmlResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $crawler = $event->getDomCrawler();
     $nodes = $crawler->filterXPath('descendant-or-self::img[@src]');
     $urls = $nodes->extract('src');
     $this->processUris($event, $dispatcher, $urls, 'image');
 }