Get Alexa Rank

Yêu cầu: Hỗ trợ curl, file_get_contents.

<?php
$url = $_GET['url'];
function getPage ($url) {
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
return curl_exec($ch);
} else {
return file_get_contents($url);
}
}
function getAlexaRank($url) {
$url = @parse_url($url);
$url = $url['host'];
$url = "http://data.alexa.com/data?cli=10&dat=s&url=$url";
$data = getPage($url);
preg_match('#<POPULARITY URL="(.*?)" TEXT="([0-9]+){1,}"/>#si', $data, $p);
$value = ($p[2]) ? number_format($p[2]) : 0;
return $value;
}
$Rank = getAlexaRank($url);
echo $Rank;
?>

Chạy file: file.php?url=http://thuongtin.net

Popularity: 14% [?]


  1. No comments yet.

  1. No trackbacks yet.

Chọn kiểu gõ: Tự động TELEX VNI Tắt

Bad Behavior has blocked 48 access attempts in the last 7 days.