{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Create a Trove OCR corrections ticker" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Run this cell first to set things up\n", "import requests\n", "import time\n", "from IPython.display import display, HTML, clear_output\n", "params = {\n", " 'q': 'has:corrections',\n", " 'zone': 'newspaper',\n", " 'encoding': 'json',\n", " 'n': '0',\n", " 'key': 'ju3rgk0jp354ikmh'\n", "}\n", "\n", "def update_corrections():\n", " try:\n", " while True:\n", " clear_output(wait=True)\n", " response = requests.get('http://api.trove.nla.gov.au/v2/result', params=params)\n", " data = response.json()\n", " total = int(data['response']['zone'][0]['records']['total'])\n", " display(HTML('

Trove users have made corrections to {:,} newspaper articles.

'.format(total)))\n", " time.sleep(5)\n", " except KeyboardInterrupt:\n", " pass" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

Trove users have made corrections to 11,998,162 newspaper articles.

" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Run this cell to start the ticker\n", "# To stop, click the stop button or select Kernel > Interrupt from the menu\n", "update_corrections()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "\n", "Created by [Tim Sherratt](https://timsherratt.org/) for the [GLAM Workbench](https://glam-workbench.github.io/)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }