Py’otrMuhammad Toheed Sahar

Papers Past Newspaper Archive Pipeline

I built a pipeline that pulls historical New Zealand newspaper articles into a queryable dataset, with a live progress dashboard and CSV and Excel export.

Client
Self-initiated demo
Year
2026
Type
Data & pipelines

The problem

The Papers Past archive holds a very large body of digitised newspaper articles, but the website sits behind a web application firewall that blocks automated page access, so pulling the text out at scale by scraping pages was not an option.

How I built it

Instead of fighting the firewall I used the official DigitalNZ API that aggregates Papers Past and returns the full OCR text, title, publisher, date and source URL as JSON, so there is no HTML parsing at all. An async fetcher pages through the results 100 at a time with polite delays, retries and rate-limit backoff, and stores everything in SQLite with a switch to PostgreSQL for production. A Rich terminal dashboard shows live progress from a second window, and an exporter writes CSV and Excel files with a per-publisher summary.

What got hard

  1. The Papers Past website blocks automated traffic with a web application firewall.

    I moved to the official DigitalNZ API, the sanctioned route to the same records. It is stable, structured and has the full text already extracted, which removed the need for proxies or page parsing.

  2. A run over an archive this size has to survive interruptions and rate limits.

    The run can resume from any page number, retries wait longer after each rate-limit response, and an optional API key raises the limits. A unique ID per article and SQLite in WAL mode stop duplicates when a run is restarted.

The result

A 1,000-article demo run on 26 March 2026 produced 402,270 words from 31 publishers, dated 1867 to 1940, exported as CSV and Excel with the per-publisher summary. An earlier 200-article run is also on disk.