Convert Wikipedia article to plaintext
Because we all love Wikipedia
The code below downloads article from Wikipedia and it's main image (if there is any). It uses a free REST API so there's no reason not to use it.<?php
$page = 'lion';
$language = 'en';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/wikipedia_page.php?page=' . $page . '&language=' . $language . '&plain=1'));
if (@$data->success !== 1)
{
die('Failed');
}
echo 'Page title=' . $data->title;
echo 'Page text=' . $data->text;
echo 'Image=' . $data->image_url;
echo 'Image width=' . $data->image_width;
echo 'Image height=' . $data->imageheight;
Comments