{ "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": [ "" ] }, "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/). \n", "Support this project by becoming a [GitHub sponsor](https://github.com/sponsors/wragge?o=esb)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 4 }