Create a Trove OCR corrections ticker¶
In [ ]:
%%capture
import os
import time
import requests
from dotenv import load_dotenv
from IPython.display import HTML, clear_output, display
load_dotenv()
In [ ]:
# Insert your Trove API key
API_KEY = "YOUR API KEY"
# Use api key value from environment variables if it is available
if os.getenv("TROVE_API_KEY"):
API_KEY = os.getenv("TROVE_API_KEY")
In [ ]:
params = {"q": "has:corrections", "category": "newspaper", "encoding": "json", "n": "0"}
headers = {"X-API-KEY": API_KEY}
In [ ]:
def update_corrections():
try:
while True:
clear_output(wait=True)
response = requests.get(
"http://api.trove.nla.gov.au/v3/result", params=params, headers=headers
)
data = response.json()
total = int(data["category"][0]["records"]["total"])
display(
HTML(
'<p style="line-height: 15rem;">Trove users have made corrections to <span style="font-size: 10rem;">{:,}</span> newspaper articles.</p>'.format(
total
)
)
)
time.sleep(5)
except KeyboardInterrupt:
pass
In [ ]:
# Run this cell to start the ticker
# To stop, click the stop button or select Kernel > Interrupt from the menu
update_corrections()
Created by Tim Sherratt for the GLAM Workbench.
Support this project by becoming a GitHub sponsor.