Skip to content

Fix PRE (Preston) scraper - #496

Open
symroe wants to merge 1 commit into
masterfrom
fix/PRE-scraper
Open

Fix PRE (Preston) scraper#496
symroe wants to merge 1 commit into
masterfrom
fix/PRE-scraper

Conversation

@symroe

@symroe symroe commented Aug 6, 2026

Copy link
Copy Markdown
Member

What broke

The scraper was hitting http://preston.moderngov.co.uk/mgWebService.asmx/GetCouncillorsByWard and receiving a 403. Preston's ModernGov instance now enforces HTTPS and is behind a Cloudflare WAF that challenges non-browser HTTP clients — wreq's TLS fingerprint is blocked at the WAF layer, returning 403 before the ASMX response is served.

What was fixed

  • Changed base_url from http://preston.moderngov.co.uk to https://preston.moderngov.co.uk in metadata.json
  • Added http_lib = "playwright" to use headless Chromium in Lambda, which executes the Cloudflare JS challenge and retrieves the XML endpoint content

Scrape results

Local testing is blocked by the same Cloudflare WAF from this environment. Counts will be confirmed on the next Lambda run after merge.

Metric Count
Councillors found TBC (Lambda run needed)
With email address TBC
With photo TBC

Generated by Claude Code

The scraper was using an http:// base URL for the ModernGov endpoint.
Preston's moderngov instance now requires HTTPS and is protected by a
Cloudflare WAF that returns 403 to non-browser clients. Switching to https://
and using Playwright (headless Chromium) allows the JS challenge to be
executed and the XML endpoint to be reached cleanly in Lambda.
@symroe

symroe commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Re-scrape after e305240

Initial fix: HTTPS migration + Playwright for Cloudflare bypass.

Cloudflare blocks all non-Chromium clients from this environment (both wreq and curl receive a connection reset or 403 challenge page), so scrape counts can only be confirmed after a Lambda run where headless Chromium will execute the JS challenge.

Metric Count
Councillors found TBC (Lambda run needed)
With email address TBC
With photo TBC

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants