最新消息: 新版网站上线了!!!

php自定义百度搜索引

以下代码只提学习使用
require 'Snoopy.class.php';
header("Content-type:text/html;charset=utf-8");
$snoopy = new Snoopy;
//var_dump($_SERVER);
$snoopy->agent = "'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36";
$wd = isset($_GET['wd']) ? urlencode($_GET['wd']) : 1;
$oq = isset($_GET['oq']) ? urlencode($_GET['oq']) : '1' ;
$pn = isset($_GET['pn']) ? $_GET['pn'] : '10' ;
$bs = isset($_GET['bs']) ?urlencode($_GET['bs']) : '' ;
$snoopy->referer = "http://www.baidu.com";
$snoopy->fetch("http://www.baidu.com/s?wd={$wd}&pn={$pn}&oq={$oq}&ie=utf-8&usm=1&bs={$bs}");
echo "";
$str = str_ireplace('action="/s"','action="?"',$snoopy->results);
$str = str_ireplace('class="n"','',$str);
$str = str_ireplace('百度为您找到相关结果约','为您找到相关结果约',$str);
$str = str_ireplace('百度一下','互联网搜索',$str);
$str = str_ireplace('/s?','?',$str);
echo $str;
源码下载
http://www.kuitao8.com/h9mpcqir

转载请注明:谷谷点程序 » php自定义百度搜索引