这个等于是用户的搜索习惯。等于是用户搜索喜好信息,热搜词。相当于百度已经做过一次数据分析。他的目的是捡百度的便宜,直接多分析几个关键词或者搜索引擎,就可以拿到一份相对有价值的用户喜好分析报告。
php提取百度下拉框的搜索词,如下:
<?php /** * @Author: allen * @Date: 2015-05-19 21:58:08 * @Last Modified time: 2015-05-19 22:25:36 */ ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style> .mydiv{ background: #ccc; border: 1px solid blue; margin: 0 auto; width: 50%; } </style> </head> <body> <?php @$word=$_GET['word']; if ($word==""){ echo <<<EOF <div class="mydiv"> <form action="" method="get"> <p>关键词: <input type="text" name="word" /></p> <input type="submit" value="提取" /> </form> </div> 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 "<br />".$wd[$n]; } } ?> </body> </html>
- 我的微信
- 这是我的微信扫一扫
- 我的微信公众号
- 我的微信公众号扫一扫