Urgent.News

What's breaking now, across hundreds of outlets.

Tech

I searched Google Hotels for a city that does not exist. It found five hotels.

I typed "hotels in Qwzxvbnmplk" into my Google Hotels scraper to watch it fail. It did not fail. It came back with five hotels near San Antonio, Texas, each with a price, a rating and a map position. This is the story of that answer and the fix. It is also how my fix broke a real capital city, and the small check I now run before I trust any search result. A test that was supposed to fail On 8…

On October 8th, the author was testing inputs that should fail by searching for cities that do not exist. They entered "hotels in Qwzxvbnmplk" into Google Hotels and received five hotel results near San Antonio, Texas, each with prices, ratings, and coordinates. The scraper charged for these priced hotels, even though the search input was nonsensical.

The author discovered that Google always tries to answer a query, even if it cannot find an exact match, by showing hotels nearby. They implemented a fix that resolved the place first, skipped the search if no place was found, and added a field called "resolvedPlace" to identify the understood place. However, this fix broke a real capital city, Prague, as Google sent a page for Prague without its place data.

The author then added a retry mechanism for missing places, but this still led to incorrect results. The author concludes by providing a simple check that can be used to validate the answers from various sources, such as geocoders, search APIs, or entity lookups.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

I searched for Nike and my scraper never found Nike

I asked my Google Ads Transparency scraper for the ads of "nike". It returned ads from two advertisers called Nikena and nikey.

  • Scraper searched for Nike ads but found Nikena and nikey instead
  • Bug in scraper code led to inaccurate advertiser suggestion
  • Fix added match scores and timestamps for ad comparison

More from Friday 9 October →