Extract meta tags from a website
By: Daniel

Have you ever wanted to get the meta tags from any website in an easy to manage way? There is a built in PHP function called get_meta_tags. This extracts all meta tags from the website and places them in an array. This array contains the tag name as the key, then the value is the data for the meta tag.

<?php
echo '<pre>'; // Make the tags easier to read with <pre>
// Get meta information of "http://www.wlscripting.com"
$metaTags = get_meta_tags('http://www.wlscripting.com');

// Print the array
print_r($metaTags);
echo '</pre>';
?>

This would produce an output of:

Array
(
    [keywords] => wlscripting, white lake scripting, whitelake, scripting, php, classes, code, counters, mysql, data validation, csv, free
    [description] => PHP Tutorials
    [author] => Daniel Kassner
    [robots] => ALL
)

You can then easily loop through the $metaTag variable to do anything you wished with the data.

**Note: You may also use the path to a file instead of a web address to achieve the same results.

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4.60 out of 5)
Loading ... Loading ...

One Response to “Extract meta tags from a website”

  1. htc pure Says:

    i’ve had my pure for per week now and that i still dont know what to do… like changing the message alert tone to whatever i want it not just the fundamental ones on the phone… every little thing about this phone is complicating.. i additionally needed to change to that android software program as a result of home windows is just too slow and someone please help me how to do this

Leave a Reply

geovisitors