Fix STF (Staffordshire Moorlands) scraper#411
Open
symroe wants to merge 1 commit into
Open
Conversation
… not ID 1414 The scraper filters to only include councillors with a staffsmoorlands.gov.uk email address, with a special exception for councillor ID 1414 who is known to have no email listed. The bug: when a councillor (other than 1414) has no email attribute, the guard block entered via `if not getattr(councillor, "email", None)` only returned early for ID 1414 — all other emailless councillors fell through to `if "staffsmoorlands.gov.uk" in councillor.email:` which raised AttributeError because the attribute is absent, not None. Fix: add `raise SkipCouncillorException()` as the else-branch so that any councillor without an email (and not the known exception 1414) is silently skipped rather than crashing the entire run.
Member
Author
Re-scrape after 91c500fInitial push: added The ModGov endpoint (
Counts will be updated here after the next Lambda run confirms the fix. 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
The scraper filters councillors by email domain, keeping only those with a
staffsmoorlands.gov.ukaddress. Councillor ID 1414 is a known exception (no email listed). On June 30 a second councillor appeared in the ModGov XML without an email attribute set on theCouncillorBaseobject.The guard at line 8 (
if not getattr(councillor, "email", None)) correctly detected the missing email, but the block only returned early for ID 1414. Any other emailless councillor fell through to line 12 (if "staffsmoorlands.gov.uk" in councillor.email:) which raisedAttributeError: 'CouncillorBase' object has no attribute 'email', crashing the entire run.What was fixed
raise SkipCouncillorException()as the else-branch inside theif not getattr(councillor, "email", None):block, so any councillor without an email who is not the known exception (ID 1414) is silently skipped rather than crashing the run.Scrape results
The ModGov endpoint returns 403 from this environment so exact counts require a Lambda run. Based on the XML structure (ModGov
GetCouncillorsByWard), the council has 56 seats; the scraper previously ran successfully with ~56 councillors.Generated by Claude Code