{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Create a Trove OCR corrections ticker" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [] }, "outputs": [], "source": [ "# Run this cell first to set things up\n", "import time\n", "\n", "import requests\n", "from IPython.display import HTML, clear_output, display\n", "\n", "params = {\n", " \"q\": \"has:corrections\",\n", " \"zone\": \"newspaper\",\n", " \"encoding\": \"json\",\n", " \"n\": \"0\",\n", " \"key\": \"ju3rgk0jp354ikmh\",\n", "}\n", "\n", "\n", "def update_corrections():\n", " try:\n", " while True:\n", " clear_output(wait=True)\n", " response = requests.get(\n", " \"http://api.trove.nla.gov.au/v2/result\", params=params\n", " )\n", " data = response.json()\n", " total = int(data[\"response\"][\"zone\"][0][\"records\"][\"total\"])\n", " display(\n", " HTML(\n", " '
Trove users have made corrections to {:,} newspaper articles.
'.format(\n", " total\n", " )\n", " )\n", " )\n", " time.sleep(5)\n", " except KeyboardInterrupt:\n", " pass" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "tags": [ "nbval-skip" ] }, "outputs": [ { "data": { "text/html": [ "Trove users have made corrections to 13,590,152 newspaper articles.
" ], "text/plain": [ "