模拟百度搜索接口输出关键词

<!DOCTYPE  html >
<html  lang= "en" >
<head>
    <meta  charset= "UTF-8" >
    <title>Title </title>
    <style>
        *{ padding: 0 ; margin: 0 ;}
        li{ list-style: none ;}
        #container{ positionrelative ; width: 800 px ; height: 50 px ; padding: 50 px ; border: 1 px solid  #EAA90B ; margin: auto ;}
        #search{ width: 450 px ; height: 50 px ; line-height: 50 px ; font-size: 30 px ; box-sizing: border-box ; float: left ;}
        button{ width: 200 px ; height: 50 px ; float: left ;}
        img{ float: left}
        ul{ positionabsolute ; top: 100 px ; left167 px ; displaynone ;}
        li{ font-size: 30 px ; line-height: 50 px ; border1 px dashed  #4FEF10 ; width: 448 px ;}
    </style>
</head>
<body>
<div  id= "container" >
    <img  src= "baidu.gif"  alt= "" >
    <input  type= "text"  id= "search" >
    <button> 百度一下 </button>
    <ul  id= "lis" >
    </ul>
</div>
<script>
    search. onkeyup function(){
        var _sc =  document. createElement( "script") ;
        _sc. src "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + search. value + "&cb=Search" ;
        document. body. appendChild(_sc) ;
    }
    search. onblur function(){
        lis. textContent "" ;
    }
    function  Search(str){
        console. log(str) ;
        lis. textContent "" ;
        lis. style. display "block" ;
        for( var i =  0 ;i < str.s. length ;i++){
            var _li =  document. createElement( "li") ;
            _li. textContent = str.s[i] ;
            lis. appendChild(_li) ;
        }
    }
</script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值