{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MediaWiki API (part 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's request the https://pzwiki.wdka.nl/mediadesign/Dérive page.\n", "\n", "(I made a copy of the page of last week, to make the URL a bit simpler :).)\n", "\n", "And let's try to save different versions of it as .html pages, using the API. " ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [], "source": [ "import urllib\n", "import json\n", "from IPython.display import JSON" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Make an API request" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is how we did an API request to the PZI MediaWiki last week:" ] }, { "cell_type": "code", "execution_count": 112, "metadata": {}, "outputs": [], "source": [ "url = 'https://pzwiki.wdka.nl/mw-mediadesign/api.php?action=parse&page=D%C3%A9rive&format=json' # urllib doesn't like the \"é\", so we're writing it in ASCII\n", "request = urllib.request.urlopen(url).read()\n", "data = json.loads(request)" ] }, { "cell_type": "code", "execution_count": 113, "metadata": {}, "outputs": [ { "data": { "application/json": { "parse": { "categories": [], "displaytitle": "Dérive", "externallinks": [ "https://sites.google.com/a/cougars.csusm.edu/20-poetry/my-20-project/theexpansionalookintohypertext" ], "images": [ "Debo_009_05_01.jpg", "Sex-majik-2004.gif" ], "iwlinks": [], "langlinks": [], "links": [ { "*": "Hi", "exists": "", "ns": 0 }, { "*": "Hyper Poetry", "exists": "", "ns": 0 }, { "*": "Hypertext", "exists": "", "ns": 0 }, { "*": "Wiki Tutorial", "exists": "", "ns": 0 } ], "pageid": 33524, "parsewarnings": [], "properties": [], "revid": 188107, "sections": [], "templates": [ { "*": "Template:Youtube", "exists": "", "ns": 10 } ], "text": { "*": "
hi\n
Refresh your memory here :Wiki_Tutorial\n
Hypertext\nHypertext: An Educational Experiment in English and Computer Science at Brown University\n
\n
Hyper Poetry\nWhat it is? [1]\n
\n\n\n\n\n\n\nhi\n", "
Refresh your memory here :Wiki_Tutorial\n", "
Hypertext\n", "Hypertext: An Educational Experiment in English and Computer Science at Brown University\n", "
\n", "
Hyper Poetry\n", "What it is? [1]\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "