从Wikipedia API提取数据 [英] Extracting data from Wikipedia API

查看:128
本文介绍了从Wikipedia API提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用json从Wikipedia中提取标题和描述.所以...维基百科不是我的问题,我是json的新手,并且想知道如何使用它.现在我知道有成百上千的教程,但是我已经工作了几个小时,它什么也没显示,这是我的代码:

I would like to be able to extract a title and description from Wikipedia using json. So... wikipedia isn't my problem, I'm new to json and would like to know how to use it. Now I know there are hundreds of tutorials, but I've been working for hours and it just doesn't display anything, heres my code:

<?php
  $url="http://en.wikipedia.org/w/api.php?action=query&prop=extracts|info&exintro&titles=google&format=json&explaintext&redirects&inprop=url";

    $json = file_get_contents($url);
    $data = json_decode($json, TRUE);

    $pageid = $data->query->pageids;
    echo $data->query->pages->$pageid->title;
?>

只需单击它即可更轻松:

Just so it easier to click:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆