/** * {@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]); } } }
/** * {@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); } } }
/** * {@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]); } } } }
/** * {@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); } } } }
/** * {@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); } } }
/** * 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); } } }