Using Symfony's DomCrawler how can I extract meta description from html source? http://symfony.com/doc/current/components/dom_crawler.html
$crawler = new Crawler();
$crawler->addHtmlContent($html->content, 'UTF-8');
$title = $crawler->filter('title')->text();
Example MSN meta description
<meta name="description" content="The new MSN, Your customizable collection of the best in news, sports, entertainment, money, weather, travel, health, and lifestyle, combined with Outlook, Facebook, Twitter, Skype, and more."/>
I assume you are trying to get content attribute value so try to use
$data = $crawler->filterXpath("//meta[@name='description']")->extract(array('content'));
and loop through $data
.
$meta_description = $crawler->filter('meta[name="description"]')->eq(0)->attr('content');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With