通过关键词排名查询,可以快速得到当前网站的关键字在Baidu的排名情况。... 通过关键词排名查询,可以快速得到当前网站的关键字在Baidu收录的排名情况!
header("Content-Type:text/html;charset=utf-8"); function s($keyword,$url,$page = 1){ static $px = 0; $rsState = false; //print_r($url).'<br/>'; $enKeyword = urlencode($keyword); //echo $enKeyword.'<br/>'; $firstRow = ($page - 1) * 3; if($page > 3){ die('10页之内没有该网站排名..end'); } $contents = file_get_contents("http://www.baidu.com/s?wd=$enKeyword&&pn=$firstRow"); //print_r($contents); preg_match_all("/<div class=\"f13\">.*?<\/a>/ism",$contents,$rs); echo "<pre>"; //print_r($rs); //die(); foreach($rs[0] as $k=>$v){ print_r($url); $px++; if(strstr($v,$url)){ //print_r($url); $rsState = true; preg_match_all('/<h3[\s\S]*?(<a[\s\S]*?<\/a>)/',$v,$rs_t); echo '当前 "' . $url . '" 在百度关键字 "' . $keyword . '" 中的排名为:' . $px; echo '<br>'; echo '第' . $page . '页;第' . ++$k . "个<a target='_blank' href='http://www.baidu.com/s?wd=$enKeyword&&pn=$firstRow'>进入百度</a>"; echo '<br>'; //PRINT_r($rs_t);die; //echo $rs_t[1][0]; //echo iconv('GBK','UTF-8//IGNORE',$rs_t[1][0]); break; } } unset($contents); if($rsState === false){ s($keyword, $url,++$page); } }
评论(0)