How to get alexa rank using php?
I tried to many script of alexa which return you the rank of website but they all script return 0 always.
so i make a new alexa script which return exact rank of website and this works.
simple copy and paste alexa script code in your php file, it will also work on localhost
<?php
function alexaRank($domain)
{
$remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
$search_for = '<POPULARITY URL';
$part='';
if ($handle = @fopen($remote_url, "r")) {
while (!feof($handle)) {
$part .= fread($handle, 100);
$pos = strpos($part, $search_for);
if ($pos === false)
continue;
else
break;
}
$part .= fread($handle, 100);
fclose($handle);
}
$str = explode($search_for, $part);
$str = array_shift(explode('"/>', $str[1]));
$str = explode('"', $str);
return $str[3];
}
echo "Alexa ranking: " . alexaRank("http://www.yahoo.com");
?>
If this post is use full to you and this alexa script works so please comment on this post! :)
happy coding
so i make a new alexa script which return exact rank of website and this works.
simple copy and paste alexa script code in your php file, it will also work on localhost
<?php
function alexaRank($domain)
{
$remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
$search_for = '<POPULARITY URL';
$part='';
if ($handle = @fopen($remote_url, "r")) {
while (!feof($handle)) {
$part .= fread($handle, 100);
$pos = strpos($part, $search_for);
if ($pos === false)
continue;
else
break;
}
$part .= fread($handle, 100);
fclose($handle);
}
$str = explode($search_for, $part);
$str = array_shift(explode('"/>', $str[1]));
$str = explode('"', $str);
return $str[3];
}
echo "Alexa ranking: " . alexaRank("http://www.yahoo.com");
?>
If this post is use full to you and this alexa script works so please comment on this post! :)
happy coding
Thank you for posting this, I found it after searching google for a few minutes. Thanks Again
ReplyDeleteChuck Lee
Thanks for come on my blog your welcome chuck lee
DeleteThanks to post this code. It make easy my work.
ReplyDelete