<?php
/**
* This is simple description.
*
* @author Vick Kumar <vickkumar2011@gmail.com>
* @copyright Seecure.me, 2012
* @version 1.0
* @license http://creativecommons.org/licenses/by/3.0/legalcode
*/
$domain = 'wjunction.com';
function GetAlexaTrafficRank($domain)
{
$source = file_get_contents("http://www.alexa.com/siteinfo/$domain#");
$regex = '/is ranked (.*) in/';
preg_match($regex, $source, $match);
$newresult = str_replace("number", "", $match[1]);
return $newresult;
}
echo $domain." 's Alexa Traffic Rank is: ".GetAlexaTrafficRank($domain).".";
?>
function GetAlexaTrafficRank($domain) {
$domain = preg_replace('#(https?://)?(www\.)?#i','',$domain);
...
<?php
/**
* This is simple description.
*
* @author Vick Kumar <vickkumar2011@gmail.com>
* @copyright Seecure.me, 2012
* @version 1.0
* @license http://creativecommons.org/licenses/by/3.0/legalcode
*/
function GetAlexaTrafficRank($domain)
{
$source = file_get_contents("http://www.alexa.com/siteinfo/$domain#");
$regex = '/is ranked (.*) in/';
preg_match($regex, $source, $match);
$newresult = str_replace("number", "", $match[1]);
return $newresult;
}
echo "Wjunction's Alexa Traffic Rank is: ".GetAlexaTrafficRank("wjunction.com").".";
?>
That's why the regex fails.The rank is calculated using a combination of average daily visitors to
wjunction.com and pageviews on wjunction.com over the past 3 months. The site with the highest combination of visitors and pageviews is ranked #1.
function GetAlexaTrafficRank($domain)
{
$source = file_get_contents("http://www.alexa.com/siteinfo/$domain#");
$regex = '#([0-9,]+)\s*</div>\s*<div class="label">Global Rank#';
preg_match($regex, $source, $match);
$newresult = str_replace("number", "", $match[1]);
return $newresult;
}
echo "Wjunction's Alexa Traffic Rank is: ".GetAlexaTrafficRank("wjunction.com").".";