Monday, November 14, 2011

curl used in php

function getReturnValue($url_send)
{
$ret_val = "";
$run_url = $url_send;
$ch = curl_init();
$url = str_replace(" ","%20",$run_url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT,25);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$ret_val = curl_exec($ch);
curl_close($ch);
return $ret_val;
}
$retCalu = getReturnValue("http://www.vdocity.com/");

//$retCalu /// call value

$doc = new DOMDocument();

@$doc->loadHTML($retCalu);
$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' || $meta->getAttribute('name') == 'Description')
$description = $meta->getAttribute('content');
if($meta->getAttribute('name') == 'keywords' || $meta->getAttribute('name') == 'Keywords')
$keywords = $meta->getAttribute('content');

if($meta->getAttribute('name') == 'author' || $meta->getAttribute('name') == 'Author' )
$author = $meta->getAttribute('content');

if($meta->getAttribute('name') == 'copyright' || $meta->getAttribute('name') == 'Copyright')
$copyright = $meta->getAttribute('content');

if($meta->getAttribute('name') == 'classification' || $meta->getAttribute('name') == 'Classification')
$classification = $meta->getAttribute('content');

if($meta->getAttribute('name') == 'robots' || $meta->getAttribute('name') == 'Robots')
$robots = $meta->getAttribute('content');

}
echo "Title: $title". '

';

echo "Keywords: $keywords". '

';

echo "Description: $description". '

';

echo "Author: $author". '

';


echo "Classification: $classification". '

';

echo "Robots: $robots". '

';


echo "Copyright: $copyright";

No comments:

Post a Comment