Fix ELN (East Lothian) scraper#361
Open
symroe wants to merge 1 commit into
Open
Conversation
The council migrated from Drupal's /councillors/name to /council-and-democracy/councillors as part of a CMS upgrade to LocalGov Drupal. The old URL now returns HTTP 301, and the new page uses a completely different DOM structure (Drupal Views with accordion panes, div.card per councillor) — the old ul.list--political selector returned an empty list, causing the list index out of range error. Updated: - metadata.json: base_url to /council-and-democracy/councillors - councillors.py: container selector .view-id-councillors, item selector .card; extract name/ward/party from list-page card fields directly; fetch detail page only for email; photo from img in card
Member
Author
Re-scrape after e07b5e2New URL + selector fix applied. Scraped live against
All 22 councillors have email and photo. Photos are full-res PNGs from 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
East Lothian's website migrated from an older Drupal theme to LocalGov Drupal. The councillors list moved from
/councillors/name(which now returns HTTP 301) to/council-and-democracy/councillors. The new page uses a completely different DOM: councillors are rendered asdiv.cardelements inside a Drupal Views accordion (div.view-id-councillors), replacing the oldul.list--political/.list__itemstructure. The old container selector returned an empty list, causinglist index out of rangeatget_list_container()[0].What was fixed
metadata.json: updatedbase_urlfrom.../councillors/nameto.../council-and-democracy/councillorscouncillors.py: new container selector.view-id-councillors, item selector.card; name, ward, and party are now extracted inline from each list-page card (.views-field-title a,.views-field-field-ward .field-content,.views-field-field-party .field-content); detail page fetched only for email (a[href^=mailto]); photo taken from.views-field-field-image imgwithdata-src/srcfallbackScrape results
Verified locally against the live site (2026-06-18):
Generated by Claude Code