Make scraper resilient to Google Maps DOM changes (selector fallbacks, consent handling, geo data)#16
Open
Rmaawn wants to merge 3 commits into
Open
Make scraper resilient to Google Maps DOM changes (selector fallbacks, consent handling, geo data)#16Rmaawn wants to merge 3 commits into
Rmaawn wants to merge 3 commits into
Conversation
modified: added conditional logic for continuous check to match all the searches, modified requirements.txt to install latest packages for python 3.13
refactor: update browser path,
…data, headless flag
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.
Summary
The scraper relied on hard-coded XPaths tied to Google's obfuscated CSS classes
(e.g.
TIHn2,DUwDvf lfPIob). Google rotates these frequently, which silentlybreaks extraction. This PR reworks the core to be resilient and adds several
commonly-needed fields.
What changed
safe_text/safe_attrhelpers try aprioritized list of CSS + XPath selectors and return the first valid match,
so a single class change no longer breaks a field.
CONSENT/SOCScookies and adds adismiss_consentfallback, preventing the scraper from getting stuck onconsent.google.com./maps/search/...instead of typing into the search box (more stable, fewer race conditions).
scroll_resultsdetects the end-of-list markerand stops on stale rounds instead of fixed sleeps.
latitude,longitude,plus_code, andgoogle_maps_urlparsed from the place URL.
--headlessflag andutf-8-sigCSV output (correct Unicode in Excel).Notes
fallback layer makes failures degrade gracefully instead of breaking outright.