feat: added two google carousel parsers#392
Draft
Ed-Lovera wants to merge 1 commit into
Draft
Conversation
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.
Overview
nokolexborgem.rspecgem.LCA Container Detection: The parser finds the Lowest Common Ancestor (LCA) container of all elements that match the carousel criteria (contain an image, text, and Google search path).
Dynamic Header Resolution: Starting at the LCA container, the parser walks up the DOM parent tree to find the nearest local section header (supporting standard
h2/h3tags, ARIA headings, and Google entity titles). The last word of the header is used as the dynamic JSON key (e.g.,"artworks","books","albums").Nokolexbor
::textSelector: Rather than manually filtering nested tags and children to find text nodes. This allows us to grab text values directly from any container tags (making parsing tag-agnostic).Thumbnail Resolution: Google loads the first carousel images using deferred script blocks at the bottom of the page. The parser scans the
<script>blocks to build an ID-to-Base64 map, resolves any escape sequences, and maps them to image elements (falling back to thedata-srcattribute if they are not script-loaded).Why There Are Two Versions?
The parser was split into two versions because of minor conflicts in the code challenge instructions:
Version One (
GoogleCarouselParserOne)README.mdfile."image"key) completely."link"inside a string array (e.g.["https://www.google.com/search..."]).google_carousel_parser_one_spec.rbacross all fixtures.Version Two (
GoogleCarouselParserTwo)"image"key)."link"as a plain String.google_carousel_parser_two_spec.rb(including exact structure and element equality checks against the expected JSON array).