一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php 读取 alexa信息

时间:2009-03-19 编辑:简简单单 来源:一聚教程网

function Alexa($domain)
{
 $alexa = '';
 $content = get_content('http://www.alexa.com/data/details/traffic_details?url='.$domain);
 if(preg_match("/3 mos. Change([sS]*?)/", $content, $matches))
 {
  $change = strpos($matches[1], 'down_arrow.gif') ? '下降' : '上升';
  $p = strip_tags($matches[1], '');
  $p = trim(str_replace(array(" ", "n", ""), array('', '', ''), $p));
  $p = explode("", $p);
  if(isset($p[1])) $alexa.= ' 今日:'.$p[1];
  if(isset($p[2])) $alexa.= ' 本周:'.$p[2];
  if(isset($p[3])) $alexa.= ' 本月:'.$p[3];
  if(isset($p[4])) $alexa.= ' '.$change.':'.$p[4];
 }
 if(preg_match("/Review for $domain: (.*)
/", $content, $matches))
 {
  $alexa = $alexa.' 等级:'.$matches[1];
 }
 $alexa = 'http://www.alexa.com/data/details/traffic_details?url='.$domain.'" target="_blank">'.$alexa.'';
 return $alexa;
}

热门栏目