[代码]php代码://查询关键词排名
function rank($keyword,$site){
$num="-";
$site=str_replace("http://","",$site);
$keyword=str_replace(" ","",$keyword);
$url="http://www.baidu.com/s?rn=100&wd=".$keyword;
$content=file_get_contents($url);
if(count(explode("200",$http_response_header[0]))<2)
return "查询请求超时";
preg_match_all("/
$rs1=$tablearr[0];
foreach($rs1 as $v){
preg_match("/(.*)[\d]{4}-[\d]{1,2}-[\d]{1,2}/U",$v,$site_p);
$sitec=strip_tags($site_p[1]);
if(strpos($sitec,$site)!==false){
preg_match("/id=(.*)>
/U",$v,$id);$num=preg_replace("/[^\d]/U","",$id[1]);
break;
}
}
return $num;
}
echo rank('PHP二次开发网',"www.php2.cc");