/**
  * 
  * @param WebPage $webPage
  * @return array
  */
 private function findStylesheetHrefs(WebPage $webPage)
 {
     $hrefs = [];
     $rootDom = new \DOMDocument();
     @$rootDom->loadHTML($webPage->getContent());
     $linkElements = $rootDom->getElementsByTagName('link');
     foreach ($linkElements as $linkElement) {
         if ($this->isLinkElementStylesheetElementWithHrefAttribute($linkElement)) {
             /* @var $linkElement \DOMElement */
             $hrefs[] = trim($linkElement->getAttribute('href'));
         }
     }
     return $hrefs;
 }
Пример #2
0
 /**
  *
  * @param string $cssSelector
  * @param array $options
  * @return \QueryPath\DOMQuery 
  */
 public function getDomQuery($cssSelector, $options = array())
 {
     $options += array('ignore_parser_warnings' => TRUE, 'convert_to_encoding' => 'ISO-8859-1', 'convert_from_encoding' => 'auto', 'use_parser' => 'html');
     return new \QueryPath\DOMQuery($this->webPage->getContent(), $cssSelector, $options);
 }