Skip to main content
← Lab

The Somerton scraper, and the alert that never fired

I run Somerton RFC’s website for the club, for free. Before it, a volunteer updated fixtures and league positions by hand every week, and they were usually a few days stale. Now a .NET console app reads England Rugby’s fixtures and results system, GMS, and writes the data to the site’s database, so nobody types it in.

One run

A Windows scheduled task runs it every day at 22:00, on weekday mornings at 07:30 and at 10:00 on Sundays. Saturday is match day: it runs every hour from 14:30, and again at 17:00 and 18:00. It loads the GMS pages in a headless browser, Playwright, and works in stages. The league table is one stage; fixtures and results are another. Each can fail on its own without taking the other down.

Fixtures sync before scores. Each GMS match is paired with the site’s event against the same opponent: on the same date if there is one, and otherwise the nearest unplayed one. Then the date, home and away, and kick-off are corrected to match GMS. The venue is only reworked when home and away swap. It never creates events. Anything it cannot pair is reported as unmatched.

That sync went in on 6 October 2026. Before it, the scraper only wrote scores onto events that already existed, so when a fixture moved the site drifted and stayed wrong: two fixtures sat on dates they were no longer being played, and one away game showed as a home match. Walkovers now sync too; they used to be skipped because they have no score.

How a run reports

Every run ends in one of four states: OK, warning, partial or failed. Failed means the run itself fell over. Partial means one stage worked and another did not. Warning means a stage came back with zero rows.

Zero rows on its own does not count as fine or as broken. The scraper also checks whether the table’s markup was on the page at all, to tell “no data yet” from “the page did not load properly”.

Healthy runs stay silent. The rest post a summary to a Discord channel, with pings blocked, because error text can contain page content.

The alert that never fired

It was not always like that. In March 2026 I added alerts through ntfy, sent on every run, OK or not, so I would know the scraper was alive.

In October the league table stage started failing. A cookie consent panel and a PageSense popup could both load late, after the step that dismisses them, and catch the click on the Tables tab. The stage failed from 23 October, and the table on the site stayed stale. No alert arrived, because the ntfy server on localhost was not running. The scraper was reporting each failure faithfully to nothing.

I fixed the popups on 3 November by hiding both with a style rule, which still applies when they arrive late. On 4 November the alerts moved to Discord, and they now post only failed, partial and warning runs, since the task can run many times on a match day.

A rounding bug

After each league table refresh, the scraper deletes rows older than the batch time. .NET timestamps carry 7 decimal places and Postgres stores 6. About half the time the stored value rounded to just below the batch time, and every row for the season was deleted straight after being written. The league table page showed “No standings available”.

The fix, on 6 October 2026, truncates the batch time to whole milliseconds, so it comes back from the database exactly as it went in.