Skip to content

Code challenge solution (Python)#396

Open
jbkela wants to merge 1 commit into
serpapi:masterfrom
jbkela:python-solution
Open

Code challenge solution (Python)#396
jbkela wants to merge 1 commit into
serpapi:masterfrom
jbkela:python-solution

Conversation

@jbkela

@jbkela jbkela commented Jul 2, 2026

Copy link
Copy Markdown

Python solution for the Van Gogh paintings carousel challenge.

Pulls the artworks carousel (name, the date as extensions, the Google link and
the thumbnail) out of the saved results page into {"artworks": [...]}. It only
reads the local HTML, no extra requests, and the output matches the provided
expected-array.json exactly, base64 thumbnails and all.

I did it in Python (BeautifulSoup + pytest) as that's my strongest language. A
few notes:

  • Items are found by their structure (a /search?...stick= link with an
    inside), not the class names, since Google changes those between pages.
  • Thumbnails come from data-src, or the base64 in the _setImagesSrc scripts (the
    padding is written as \x3d in the script so it has to be un-escaped), or null
    if it isn't in the page.
  • Tested against the given page plus real saved pages for Picasso (US), Monet
    (French) and a Power cast grid (UK), so it covers a different widget and a
    different locale, with a few small hand-written pages for the edge cases.

More detail in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant