leungeric.com

Digg del.icio.us Technorati StumbleUpon Twitter

Get Remote Webpage Information

Code Snippets | PHP | PHP | Tutorials & Resources

1 Star2 Stars3 Stars4 Stars5 Stars (3.67 out of 5)
Loading ... Loading ...

Simple code snippet to retrieve remote webpage information, including page title, page description, and keywords

<?php
$url = “http://www.leungeric.com/”;
$fp = fopen( $url, ‘r’ );
$content = “”;
while( !feof( $fp ) ) {
$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;
}

$start = ‘<title>’;
$end = ‘<\/title>’;

preg_match( “/$start(.*)$end/s”, $content, $match );
$title = $match[ 1 ];

$metatagarray = get_meta_tags( $url );
$keywords = $metatagarray[ "keywords" ];
$description = $metatagarray[ "description" ];

echo “<div>URL: $url</div>\n”;
echo “<div>Title: $title</div>\n”;
echo “<div>Description: $description</div>\n”;
echo “<div>Keywords: $keywords</div>\n”;
?>

  • Digg
  • del.icio.us
  • Technorati
  • StumbleUpon
  • Reddit
  • TwitThis
  • Sphinn
  • BlinkList
  • Furl
  • Mixx
  • NewsVine
  • Slashdot
  • Ma.gnolia
  • Facebook
  • Google
  • E-mail this story to a friend!

No Comments, Comment or Ping

Reply to “Get Remote Webpage Information”

Sponsors