× New Paste
Welcome to Amin Mahmoudi official website.
Last Blog Posts :
How to connect PHP to Microsoft SQL Server Our Private World of Warcraft Fun 3.3.5a Server Started Install GCC7 in CentOS & Ubuntu Use Telegram bot to get notifications about your MasterkinG account Unveiling new version of MasterkinG32 website 
Main Menu
User Panel
  Amin Mahmoudi - 2018/11/08 13:20 - Views : 72 -  PHP  -  Clone  -  RAW  -  Download  -  
<?php
function file_get_contents_curl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

$html = file_get_contents_curl("http://masterking32.com");

//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
//get and display what you need:
$title = $nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
$images = $doc->getElementsByTagName('img');
$imagelist = array();
for ($i = 0; $i < $metas->length; $i++)
{
    $meta = $metas->item($i);
    if($meta->getAttribute('name') == 'description')
        $description = $meta->getAttribute('content');
    if($meta->getAttribute('name') == 'keywords')
        $keywords = $meta->getAttribute('content');
}

for ($i = 0; $i < $images->length; $i++)
{
    $image = $images->item($i);
    if(!empty($image->getAttribute('src')))
	{
		 $imagelist[] = $image->getAttribute('src');
	}
}
echo "Title: $title". '<br/><br/>';
echo "Description: $description". '<br/><br/>';
echo "Keywords: $keywords<br/><br/>";
echo "Page Images:<br/>";
foreach($imagelist as $a_image)
{
	echo "<br/>".$a_image;
}
?>