<?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); ?>
时间: 2024-11-03 21:49:38