0

Hi,

below code is extracing title,keywords,descrption,links.
Need suggestions to find out IP address, Load Time, HTTP Status

<?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://servicesonclick.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');

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');
}

echo "Title: $title". '<br/><br/>';
echo "Description: $description". '<br/><br/>';
echo "Keywords: $keywords".'<br/><br/>';

$regex='|<a.*?href="(.*?)"|';
    preg_match_all($regex,$html,$parts);
    $links=$parts[1];
    foreach($links as $link){
        echo "Internal and External Links".": ". $link."<br>";
    }
?>
3
Contributors
2
Replies
21
Views
3 Years
Discussion Span
Last Post by Dinesh Kumar_1
0

I am late for reply .

<?php 
$ch = curl_init('http://www.sopantech.com/'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch); 

if(!curl_errno($ch)) 
{ 
 $cinfo = curl_getinfo($ch); 
 echo "<pre>";
print_r($cinfo);
 echo 'Page loaded in '.$cinfo['total_time'].' seconds'; 
} 

curl_close($ch); 
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.