本站实现调用百度搜索且增加搜索提示功能代码

访客4年前黑客资讯1177

之一种 ***


 var bdkeyword = "";
    $(".indexSearch input").keyup(function (e) {
        if (e.keyCode == 13) {
            window.open($(".indexSearch .btn").attr("href"), "_blank");
        } else {
            $(".indexSearch .btn").attr("href", "https://www.baidu.com/s?ie=utf-8&wd=" + $(this).val());
        }
    });
    var keyword = "";
    $(".indexSearch input").bind("input", function (e) {
        var that = $(this);
        if (keyword != that.val()) {
            var text = that.val();
            $.ajax({
                url: "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + text + "&cb=getvalue",
                dataType: "jsonp",
                type: "post",
                jsonp: "cb",
                success: function (data) {
                    if (data) {
                        laytpl($("#keywordList").html()).render(data, function (html) {
                            if (html.trim() != "") {
                                $(".selectul").show().html(html);
                            } else {
                                $(".selectul").hide().html("");
                            }
                        });
                    }
                },
                error: function (err) {
                }
            });
        }
    });
直接调用百度接口然后输出数据到


<script id="keywordList" type="text/html">
    {{#layui.each(d.s, function(index, item){}}
    <li>
        <a href="/go/?url=https://www.baidu.com/s?ie=utf-8&wd={{item}}" class="24e3-039a-1260-414f target" rel="external nofollow" target="_blank">{{item}}</a>
    </li>
    {{#})}}
</script>

第二种是自己写一个api接口 PHP代码如下



<?php
$word=$_GET["wd"];
$html = getArray($word);
$res = getHtmlByContent($html);
$result = array('p'=>'false','q'=>$word,'s' =>$res);
echo json_encode($result);
/**
 * getHtmlByContent 
 * 
 * @param mixed $html 
 * @access public
 * @return void
 */
function getHtmlByContent($html){
    preg_match_all('/<table cellpadding="0">.*<\/table>/',$html,$res);
//  print_r($res[0][0]);
    preg_match_all('/<th>.*?<\/th>/',$res[0][0],$result);
    $result = $result[0];
    if(!empty($result) && is_array($result)){
        foreach($result as $k=>$v){
            $result[$k] = strip_tags($v);
        }   
    }   
    //print_r($result);
    return $result;
}


/**
 * getArray 
 * 
 * @param mixed $kw 
 * @access public
 * @return void
 */
function getArray($kw){
    $url="http://www.baidu.com/s?wd=".$kw;
    $curl=curl_init();
    curl_setopt($curl,CURLOPT_URL,$url);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
    //curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
    $data = curl_exec($curl);
    $data = preg_replace("/[\r\n\t]+/","",$data);
    return $data;

}

服务器配置差的情况下 *** 1明显快于 *** 二


相关文章

黑客包括,怎么黑客进别人的微信,黑客改别人家密码

此刻,咱们应该先确认分组,几个为一组,先损坏第一组加密然后损坏第二组加密,然后确认解密后json数据为, #get python script version from pythonx.x.dllFi...

竞品分析:小睡眠VS蜗牛睡眠

竞品分析:小睡眠VS蜗牛睡眠

跟着社会成长,糊口程度提高,尚有人口代际更替,心理康健处事需求不绝增长,心理康健的市场需求越来越大。本文对小睡眠及蜗牛睡眠的举办了梳理,并从定位、内容和成果阐明小睡眠和蜗牛睡眠之间的不同,最后从SWO...

华为手机黑客代码(华为手机代码大全)-黑客技术找回qq密码

华为手机黑客代码(华为手机代码大全)-黑客技术找回qq密码

华为手机黑客代码(华为手机代码大全)(tiechemo.com)一直致力于黑客(HACK)技术、黑客QQ群、信息安全、web安全、渗透运维、黑客工具、找黑客、黑客联系方式、24小时在线网络黑客、黑客业...

wangle被黑钱出款失败注单异常审核风控客服各种理由不给出款怎么办?_专业出黑

遇到黑网站处理方法1,看准黑网站所需, 帮助你追回损失+微/信j    黑网站虽黑,那就是想要更多的客户和哄骗更多客户的钱。这样我们就看到了网站所需,利用网站需要客户的心里。假装自己愿意和黑网合作,做...

大学生打击黑客团伙(自学黑客被抓事件)

大学生打击黑客团伙(自学黑客被抓事件)

本文导读目录: 1、盘点一下,有哪些著名的黑客入侵案? 2、湖北一大学生化身黑客入侵电商平台隔空盗走73万,最终得到了什么处罚? 3、90后少年竟开起黑客论坛 信息安全该如何整治 4、大学...

星际穿越结局解析,找黑客手机定位软件下载,黑客怎么定位找手机

View-source:/includes/functions.phpbody>} 0 WindowsNmap scan report for 192.168.20.4 a...