基本上百度建议关键字的利用方式如下:
1、在页面中新建一个form表单
2、表单中包含两个input元素,id必须固定:
<input type="text" id="kw"> <input type="button" id="su" value="搜索">
3、引入js文件,并启动:
<script type="text/javascript">var bds = {se:{},comm:{sid:"1461_1945_2202_1788_2250"}};</script> <script type="text/javascript" src="http://s1.bdstatic.com/r/www/cache/global/js/home-2.10.js" charset="gbk"></script> <script type="text/javascript">bds.se.sug();</script> # 注意:上面的顺序不能改变!
4、在线演示,印象搜索:http://www.impress.pw/
5、完整html如下:
<!DOCTYPE html> <html itemscope="" itemtype="http://schema.org/WebPage"> <head> <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>百度建议关键字提示 ... </title> </head> <body> <form action="xxx"> <input type="text" id="kw"> <input type="button" id="su" value="搜索"> </form> <script type="text/javascript">var bds = {se:{},comm:{sid:"1461_1945_2202_1788_2250"}};</script> <script type="text/javascript" src="http://s1.bdstatic.com/r/www/cache/global/js/home-2.10.js" charset="gbk"></script> <script type="text/javascript">bds.se.sug();</script> </body> </html>
Have Fun! 可以的话,记得点赞。