Menu

My search scraper returned zero results, and HTTP 200 said everything was fine
📰

My search scraper returned zero results, and HTTP 200 said everything was fine

DEV Community: ruby·Divyanshu Kumar·15 days ago
#dX3khPrL
#devtoruby#devto#dev#rso#search
Long article (705 words) — no AI summary yet.
Reading 0:00
15s threshold

I built MiniSERP to learn how a search results API works underneath. It's a small Rails 8 API that takes a Google results page and turns it into clean JSON: title, link, snippet, position.

The first version worked on the first page I tested. I wrote the specs and they passed, and I thought the parser was done.

Then I saved a second results page with a different query and ran it through the same parser. I got back an empty array with HTTP 200.

Why that response was dangerous

An empty array with a 200 looks exactly like "Google found nothing for this query." Nothing crashed and nothing showed up in the logs. If I had shipped this, every search would have come back empty, and the API would have reported success every time.

The cause turned out to be simple. I ran a quick check on the new page:

grep -c 'class="g"' page2.html # 0

Enter fullscreen mode

Exit fullscreen mode

My parser looked for results inside div.g .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.