zoukankan      html  css  js  c++  java
  • 谷歌搜索自动补全

    <?php
        header("Content-type: text/json; charset=utf-8");
        if(isset($_POST['w'])){
            $word=$_POST['w'];
        }else if(isset($_GET['w'])){
            $word=$_GET['w'];
        }else{
            $word="空内容";
        }
        $url="http://209.85.228.22/complete/search?client=hp&hl=zh-CN&sugexp=msedr&gs_rn=64&gs_ri=hp&cp=3&gs_id=3wx&q={$word}&xhr=t";
        $text=file_get_contents($url);
        $text=iconv('GB2312', 'UTF-8', $text);
        $arr=json_decode($text,true);
        $i=0;
        foreach( $arr[1] as $key => $value )
        {
            foreach( $value as $k => $v )
            {
                if($v!="0"){
                    $list[$i]=$v;
                    $i++;    
                }
            }
        }
        $data['word']=$arr['0'];
        $data['list']=$list;
        echo json_encode($data,true);
    ?>
  • 相关阅读:
    PHP PDO
    常用JavaScript字符串方法简述
    命名
    jquery远程班备忘
    html历史
    CSS3的翻转效果
    正则
    排序算法
    firebug的调试,console
    跨域
  • 原文地址:https://www.cnblogs.com/yutaoyao/p/4459967.html
Copyright © 2011-2022 走看看