示例#1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!($html = $this->request->getHtmlContent())) {
         return false;
     }
     foreach (Utils::getMetas($html) as $meta) {
         if (stripos($meta[0], 'dc.') === 0) {
             $this->bag->set(substr($meta[0], 3), $meta[1]);
         }
     }
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!($html = $this->request->getHtmlContent())) {
         return false;
     }
     foreach (Utils::getMetas($html) as $meta) {
         list($name, $value) = $meta;
         if (strpos($name, 'sailthru.') === 0) {
             $this->bag->set(substr($name, 9), $value);
         }
     }
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!($html = $this->request->getHtmlContent())) {
         return false;
     }
     foreach (Utils::getMetas($html) as $meta) {
         foreach (['dc.', 'dc:', 'dcterms:'] as $prefix) {
             if (stripos($meta[0], $prefix) === 0) {
                 $key = substr($meta[0], strlen($prefix));
                 $this->bag->set($key, $meta[1]);
             }
         }
     }
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!($html = $this->request->getHtmlContent())) {
         return false;
     }
     foreach (Utils::getMetas($html) as $meta) {
         list($name, $value) = $meta;
         if (strpos($name, 'twitter:') === 0) {
             $name = substr($name, 8);
             if ($name === 'image') {
                 $this->bag->add('images', $value);
             } else {
                 $this->bag->set($name, $value);
             }
         }
     }
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!($html = $this->request->getHtmlContent())) {
         return false;
     }
     foreach (Utils::getMetas($html) as $meta) {
         list($name, $value) = $meta;
         if (strpos($name, 'og:article:') === 0) {
             $name = substr($name, 11);
         } elseif (strpos($name, 'og:') === 0) {
             $name = substr($name, 3);
         } else {
             continue;
         }
         if ($name === 'image') {
             $this->bag->add('images', $value);
         } elseif (strpos($name, ':tag') !== false) {
             $this->bag->add('tags', $value);
         } else {
             $this->bag->set($name, $value);
         }
     }
 }
示例#6
0
文件: Html.php 项目: jooorooo/embed
 /**
  * Extract information from the <meta> elements
  *
  * @param \DOMDocument $html
  * @param Bag          $bag
  */
 protected static function extractFromMeta(\DOMDocument $html, Bag $bag)
 {
     foreach (Utils::getMetas($html) as $meta) {
         list($name, $value, $element) = $meta;
         if (!$value) {
             continue;
         }
         if ($name) {
             $name = strtolower($name);
             switch ($name) {
                 case 'msapplication-tileimage':
                     $bag->add('icons', $value);
                     continue 2;
                 default:
                     $bag->set($name, $value);
                     continue 2;
             }
         }
         if ($element->hasAttribute('itemprop')) {
             $bag->set($element->getAttribute('itemprop'), $value);
         }
         if ($element->hasAttribute('http-equiv')) {
             $bag->set($element->getAttribute('http-equiv'), $value);
         }
     }
 }