头像

php查询网站关键词排名

来源:http://school.sxbd100.com/share/28.html 2017-11-11浏览(14)  评论0

  通过关键词排名查询,可以快速得到当前网站的关键字在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);
}
}


标签: php
声明:本文为原创文章,如需转载,请注明来源daimasucai.com并保留原文链接:http://school.sxbd100.com/share/28.html

评论(0)


温馨提示:为规范评论内容,垃圾评论一律封号...

后面还有条评论,点击查看>>