php 读取 alexa信息
<?php
function Alexa($domain) {
$alexa = '';
$content = get_content('http://www.alexa.com/data/details/traffic_details?url=' . $domain);
if (preg_match("/3 mos. Change([\s\S]*?)</table>/", $content, $matches)) {
$change = strpos($matches[1], 'down_arrow.gif') ? '下降' : '上升';
$p = strip_tags($matches[1], '<td>');
$p = trim(str_replace(array(
" ",
"n",
"</td>"
) , array(
'',
'',
''
) , $p));
$p = explode("<td>", $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:</span> (.*)<br>/", $content, $matches)) {
$alexa = $alexa . ' 等级:' . $matches[1];
}
$alexa = '<a href="http://www.alexa.com/data/details/traffic_details?url=' . $domain . '" target="_blank">' . $alexa . '</a>';
return $alexa;
}本文地址:http://www.phprm.com/code/5044e3680d6fa8cdcfd71284f7484263.html
转载随意,但请附上文章地址:-)