Get Remote Webpage Information
Code Snippets | PHP | PHP | Tutorials & Resources
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”;
?>


