Fix SRY (Surrey County Council) scraper#340
Open
symroe wants to merge 1 commit into
Open
Conversation
…railing slash Surrey's ModGov endpoint (mycouncil.surreycc.gov.uk) is behind Incapsula WAF protection. Plain wreq requests return a 212-byte Incapsula JS-challenge HTML stub instead of the councillor XML, resulting in 0 councillors scraped. Setting http_lib = "playwright" causes headless Chromium to execute the Incapsula JS challenge, which sets the required cookies and triggers a redirect to the actual XML endpoint. Chrome's XML viewer embeds the raw XML elements in the page DOM, allowing BeautifulSoup (xml parser) to parse all ward/councillor elements correctly. Also removes a trailing slash from base_url in metadata.json which was causing a double-slash in the constructed API URL. Verified via playwright with ignore_https_errors=True (needed locally due to restricted Chromium CA bundle; Lambda uses system-linked Chromium where Surrey's cert is trusted): 81 councillors, 79 emails, 81 photos.
Member
Author
Re-scrape after f4f1945Added
Verified via playwright with Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
Surrey's ModGov endpoint (
mycouncil.surreycc.gov.uk) is behind Incapsula WAF protection. Plain wreq requests return a 212-byte Incapsula JS-challenge HTML stub instead of the councillor XML, resulting in 0 councillors scraped (the scraper ran without error but got no data). Additionally, thebase_urlinmetadata.jsonhad a trailing slash that produced a double-slash in the constructed API URL (https://mycouncil.surreycc.gov.uk//mgWebService.asmx/GetCouncillorsByWard).What was fixed
http_lib = "playwright"to the Scraper class — headless Chromium executes the Incapsula JS challenge, sets the required cookies, and triggers a redirect to the actual XML endpoint. Chrome's XML viewer embeds the raw XML elements in the page DOM, so BeautifulSoup's xml parser successfully finds all ward/councillor elements.base_urlinmetadata.jsonScrape results
Generated by Claude Code