Extract all meta tags from a webpage in php

Php has a built in function get_meta_tags() which extracts all meta tags of a webpage and retuns an array of it. It takes a minimum of one  parameter (the path of the webpage). which can be local or an external webpage from other site.

It parses the webpage line by line for meta and stops when it gets </head> tag.
One thing to note here that It only extracts those meta which has name attribute set.

  $metas = get_meta_tags('http://altafphp.blogspot.com');
  echo "<pre>";
  print_r($metas);
  echo "</pre>";

Extract all meta tags from a webpage in php Extract all meta tags from a webpage in php Reviewed by JS Pixels on May 25, 2012 Rating: 5

No comments:

Altaf Web. Powered by Blogger.