Alexa Sıralama

<?php 
function alexa($url){//phpstate.ulusanyazilim.com 25.02.2015
 $domain= preg_replace(array('~^https?\://~si','~[/:#?;%&].*~','~\.$~',),'',$url);
 if(preg_match('#^www.(.*)#i',$domain)){
 $domain=preg_replace('#www.#i','',$domain);
 }
 $baglan=file_get_contents("http://www.alexa.com/siteinfo/".$domain);
 preg_match_all('/class="metrics-data align-vmiddle">(.*?)<\/strong>/',$baglan,$sira);
 preg_match('/<h4 class="metrics-title">(.*?)>(.*?)<\/a>/',$baglan,$ulkebaslik);
 preg_match_all('/id="linksin-panel-content"(.*?)class="font-4 box1-r">(.*?)</si',$baglan,$backlink);
 $alexa["dunya_siralamasi"]=$sira[1][0];
 $alexa["ulke_adi"]=$ulkebaslik[2];
 $alexa["ulke_siralaması"]=$sira[1][1];
 $alexa["backlink"]=$backlink[2][0];
 return $alexa;
}

//Örnek Kullanım
$url="http://phpstate.ulusanyazilim.com";
print_r(alexa($url));
/* Çıktısı
Array
(
    [dunya_siralamasi] => 707,217
    [ulke_adi] => Turkey
    [ulke_siralaması] => 21,467
    [backlink] => 17
) */