PHP采集百度下拉框数据的脚本程序源码

LsevenTT站群哥 PHP相关PHP采集百度下拉框数据的脚本程序源码已关闭评论3,825阅读模式

PHP采集百度下拉框数据的脚本程序PHP源码

代码如下

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="//www.lseventt.net/images/style.css"/></meta>
</head>
<body>
<?php
$word=$_GET['word'];
if ($word=="")
{
echo <<<EOF
<form action="" method="get">
<p>关键词: <input type="text" name="word" /></p>
<input type="submit" value="<span class='wp_keywordlink_affiliate'><a href="http://www.Lseventt.com/index.php?s=%E7%AB%99%E7%BE%A4" title="查看站群中的全部文章" target="_blank">站群</a></span>" />

EOF;
}
else
{

$data=file_get_contents('http://suggestion.baidu.com/su?wd='.$word);
$data=mb_convert_encoding($data, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' );
$data_temp=strpos($data,"x");
$data=substr_replace($data,"",$data_temp,17);
$data = trim($data,");");
$data = trim($data,"{");
$data=preg_replace("/q:.+?.e,/",'', $data);
$data = str_replace("[","",$data);
$data = str_replace("]","",$data);
$data = "[".$data."]";
$data = str_replace(",","},s:",$data);
$data = str_replace("s:","{\"s\":",$data);//复杂的处理,以符合json格式
$dc=json_decode($data);
for ($n = 0; $n < = 9; $n++)
{
$wd[$n]=$dc[$n]->s;
echo "".$wd[$n];
}

}
?>
</body>
</html>

 

 

文章末尾固定信息

weinxin
我的微信
我的微信
微信扫一扫
 
LsevenTT站群哥
  • 本文由 LsevenTT站群哥 发表于 2013年6月30日 23:23:16
  • 转载请务必保留本文链接:https://lseventt.net/archives/346.html