提示:URL中的 #content# 为搜索的 关键字
谷歌(Google)
<a href="http://suggestqueries.google.com/complete/search?client=youtube&q=%E5%85%B3%E9%94%AE%E5%AD%97&jsonp=window.google.ac.h" target="_blank">http://suggestqueries.google.com/complete/search?client=youtube&q=#content#&jsonp=window.google.ac.h</a>
callback:window.google.ac.h
必应(Bing)
<a href="http://api.bing.com/qsonhs.aspx?type=cb&q=%E5%85%B3%E9%94%AE%E5%AD%97&cb=window.bing.sug" target="_blank">http://api.bing.com/qsonhs.aspx?type=cb&q=#content#&cb=window.bing.sug</a>
callback:window.bing.sug
百度(Baidu)
<a href="http://suggestion.baidu.com/su?wd=%E5%85%B3%E9%94%AE%E5%AD%97&cb=window.baidu.sug" target="_blank">http://suggestion.baidu.com/su?wd=#content#&cb=window.baidu.sug</a>
callback:window.baidu.sug
好搜(So)
<a href="https://sug.so.360.cn/suggest?encodein=utf-8&encodeout=utf-8&format=json&word=%E5%85%B3%E9%94%AE%E5%AD%97&callback=window.so.sug" target="_blank">https://sug.so.360.cn/suggest?encodein=utf-8&encodeout=utf-8&format=json&word=#content#&callback=window.so.sug</a>
callback:window.so.sug
搜狗(Sogou)
<a href="https://www.sogou.com/suggnew/ajajjson?type=web&key=%E5%85%B3%E9%94%AE%E5%AD%97" target="_blank"> https://www.sogou.com/suggnew/ajajjson?type=web&key=#content#</a>
callback:window.sogou.sug
淘宝(Taobao)
<a href="https://suggest.taobao.com/sug?code=utf-8&q=%E5%85%B3%E9%94%AE%E5%AD%97&callback=window.taobao.sug" target="_blank"> https://suggest.taobao.com/sug?code=utf-8&q=#content#&callback=window.taobao.sug</a>
callback:window.taobao.sug
---------------------------------------搜索建议使用方式---------------------------------------------
下面是一个回调搜索建议的例子,window.baidu.sug 返回的是一个json对象
控制台打印的结果:如果要将结果保存在一个字符串数组中,只需要 var arr = json.s 即可。
本文转自 风雨萧条 博客,原文链接: 如需转载请自行联系原作者