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.

[code lang=”php”] echo '

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

// Print the array
print_r($metaTags);
echo '

‘;
?>[/lang]

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.

3 Votes | Average: 4.33 out of 53 Votes | Average: 4.33 out of 53 Votes | Average: 4.33 out of 53 Votes | Average: 4.33 out of 53 Votes | Average: 4.33 out of 5 (3 votes, average: 4.33 out of 5)
Loading ... Loading ...
del.icio.us:Extract meta tags from a website digg:Extract meta tags from a website spurl:Extract meta tags from a website wists:Extract meta tags from a website simpy:Extract meta tags from a website newsvine:Extract meta tags from a website blinklist:Extract meta tags from a website furl:Extract meta tags from a website reddit:Extract meta tags from a website fark:Extract meta tags from a website blogmarks:Extract meta tags from a website Y!:Extract meta tags from a website smarking:Extract meta tags from a website magnolia:Extract meta tags from a website segnalo:Extract meta tags from a website

Leave a Reply

eXTReMe Tracker
geovisitors