Remote Meta Tag and Title Script

Posted By: Ian on Feb 26, 2014 in PHP, Snippets
Last modified on January 29th, 2015 at 9:31 pm,

Today i share the basics of (Which i own) which is a script for extracting the following from a remote webpage: –

  • Title
  • Description
  • Keywords
  • Author
  • Copyright
  • Email

Using fopen is only good if it’s enabled in your php.ini else you should probably use CURL

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Remote Meta Tag and Title Retrieval</title>
<style type="text/css">
.db-table {
border-bottom : 0.063em solid #ccc;
border-right : 0.063em solid #ccc;
margin : 0 auto;
text-align : left;
background : #fff;
.db-table th {
background : #E8E8E8;
border-left : 0.063em solid #ccc;
border-top : 0.063em solid #ccc;
padding : 0.313em;
.db-table td {
border-left : 0.063em solid #ccc;
border-top : 0.063em solid #ccc;
padding : 0.313em;
$uri = "";
//a function to check whether the url exists or not and validate it
function check_url($uri)
$check = @fopen($uri, "r"); // we are opening url with fopen
if ($check)
$status = true;
$status = false;
return $status;
if (check_url($uri)) {
$check = @fopen($uri, "r"); // we are opening url with fopen
$text = @fread($check, 16384);
if (preg_match('/<title>(.*?)</title>/is', $text, $found)) {
$title = $found[1];
} else {
$title = " <-- No title found --> ";
$tags = get_meta_tags($uri);
$description = (!empty($tags['description']) ? $tags['description'] : 'No description tag found');
$keywords = (!empty($tags['keywords']) ? $tags['keywords'] : 'No keywords tag found');
$author = (!empty($tags['author']) ? $tags['author'] : 'No author tag found');
$copyright = (!empty($tags['copyright']) ? $tags['copyright'] : 'No copyright tag found');
$email = (!empty($tags['email']) ? '<a href="mailto:' . $tags['email'] . '" title="email webmaster">' . $tags['email'] . '</a>' : 'No email tag found');
$message = <<<OUTPUT
<table cellpadding="0" cellspacing="0" class="db-table">
<caption>Results for: <a href="$uri">$uri</a></caption>
<th>Page Title</th>
if (!empty($message)) {
echo $message;

Try MeDownload


Did this help you? Please Let me know by commenting below even if it’s just to say “Thanks”

leave a comment

About This Site

Dreams are built from lines of code well it's true!
If you can dream it you can usually code it.

I have learned so much from other people on the Internet and this site is for me to give back some of what i have learned and hope people can now learn from me.
Have fun and surf safely,

protected by copyscape duplicate content check


Powered by Banner Bar 125