Extract Knowledge Graph carousel (Van Gogh paintings) — Jason Dinsmore#393
Open
dinjas wants to merge 17 commits into
Open
Extract Knowledge Graph carousel (Van Gogh paintings) — Jason Dinsmore#393dinjas wants to merge 17 commits into
dinjas wants to merge 17 commits into
Conversation
A page can match several supported data-attrids at once (e.g. da Vinci is both architect and visual artist). Picking the first by CAROUSEL_ATTRIDS order grabbed the empty architecture block and dropped all 47 paintings. Choose the matching container that actually holds image tiles instead.
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
Extracts the Knowledge Graph carousel from the saved results page into an array of
{ name, extensions, link, image }objects, reproducingfiles/expected-array.jsonexactly. The same code path handles other entity carousels (albums, buildings, cast) — only the locator changes per type.Full write-up (approach, decisions, tradeoffs) is in the README.
Checks the boxes
name,extensions, and Googlelinkextracted - output matchesexpected-array.json_setImagesSrcscripts for the first tiles, in-pagedata-srcfor the rest - no extra HTTP requests[]Running it
Run against any saved page:
A few decisions (more in README)
data-attrid(not minified classes or per-request ids, which rotate), based on allowlisted knowledge graph types and not an "any carousel-shaped container" heuristic, which may false-positive on non-entity modules like Unilever's social-media panel.extensionskept generic: only the date's meaning is known (from the paintings fixture), so each tile's second line passes through as-is.Scope
Fixtures are
en/usdesktop captures. Adding a new carousel type is a one-line locator change (adding adata-attridto the list), since locating the carousel and extracting a tile are separate concerns. I didn't pursue other locales/mobile layouts, tile dedupe, or "view more" pagination. The last would require making extra HTTP requests, which the requirements rule out.