CodeIgniter: class / library to help get meta tags from a web page?

I am using codeigniter. I guess it doesnโ€™t matter what kind of flash structure I use.

But before I write my own class, there is another one that has already been written, which allows the user to get the page title and meta tags (keywords, descriptions) of any sit ... if there are any.

Any PHP class that does this will be great.

Thanks everyone

+2
php html-parsing meta-tags codeigniter
source share
5 answers

You should take a look at this class: PHP Simple HTML DOM it works as follows:

include('simple_html_dom.php'); $html = file_get_html('http://www.codeigniter.com/'); echo $html->find('title', 0)->innertext; // get <title> echo "<pre>"; foreach($html->find('meta') as $element) echo $element->name . " : " . $element->content . '<br>'; //prints every META tag echo "</pre>"; 
+4
source share

Use the PHP curl library. It can pull other pages from the Internet and extract them as strings, and then you can parse the string using regular expressions to find the page title and meta tags.

+1
source share

You can get all the meta tags from the remote page using get_meta_tags - http://ca3.php.net/get_meta_tags

There is a class on this page to get the page and description, they also use get_meta_tags - http://www.emirplicanic.com/php/get-remote-page-title-with-php.php

You must be able to combine a bit from both to get everything you need.

+1
source share

See it please. This is a universal class to get page meta tags and do a lot more. See if you can add this to the codeigniter library. Thanks

+1
source share

With DOM / xpath

 libxml_use_internal_errors(true); $c = file_get_contents("http://url/here"); $d = new DomDocument(); $d->loadHTML($c); $xp = new domxpath($d); foreach ($xp->query("//meta[@name='keywords']") as $el) { echo $el->getAttribute("content"); } foreach ($xp->query("//meta[@name='description']") as $el) { echo $el->getAttribute("content"); } 
+1
source share

All Articles