http://accounts.fstatic.org/json/results/?callback=google
我需要从这里提取所有结果。
编辑:按ID提取结果:示例
$ result1 =结果[' 1']; $ result2 =结果[' 2'];
答案 0 :(得分:1)
$results = json_decode(file_get_contents('http://accounts.fstatic.org/json/results/?callback=google'));
答案 1 :(得分:1)
使用curl获取数据并将json解码为php中的数组。
<?php
$json=fetchPageFromURL('http://accounts.fstatic.org/json/results/?callback=google');
$obj=json_decode($json,true);
print_r($obj);
echo "<hr>";
foreach ($obj as $key => $value) {
foreach (array('result','url','v-url','title','content') as $nnn => $keyname) {
if(0===strpos($key, $keyname)){
$id=substr($key, strlen($keyname), strlen($key)-strlen($keyname));
$fin[$id][$keyname]=$value;
}
}
}
print_r($fin);
function fetchPageFromURL($url){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
?>
更新以获取详细信息并将其删除。