欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用PHP查询搜索引擎排名位置的代码

程序员文章站 2023-11-09 22:44:58
复制代码 代码如下:
复制代码 代码如下:

<?php
/*
查询谷歌"深圳摄影工作室",岚视界lansj的排名位置; 2009-10-11
lost63.com原创
在前30页中搜索
*/
$page=30; //页面数
$domain="lansj.com"; //域名
//$domain="lost63.com";
for($n=0;$n<=$page;$n++){
$url='http://www.google.cn/search?hl=zh-cn&newwindow=1&q=%e6%b7%b1%e5%9c%b3%e6%91%84%e5%bd%b1%e5%b7%a5%e4%bd%9c%e5%ae%a4&start='.$n.'0&sa=n';
//$url='http://www.google.cn/search?hl=zh-cn&lr=&newwindow=1&q=%e8%bf%b7%e5%a4%b1%e8%b7%af%e4%b8%8a&start='.$n.'0&sa=n';
$file=fopen($url,"r");
while(!feof($file))
{
$result.=fgets($file,9999);
}
if(strpos($result,$domain)==true){
echo '在第'.$n.'页找到喽<br>';
$n=$page;
}else{
echo '第'.$n.'页没有找到<br>';
}
fclose($file);
}
?>