It feels like it was a long time ago. I was experimenting with porting machine learning models to iOS in order to make a couple of picture analysing apps just for fun. One was identifying food and trying to guess calories (I know it's almost impossible to be accurate!) and another was trying to guess dog breeds. Here's a snapshot of what the dog identifier one looked like:

Dog Breed Identifier App on iOS

Unfortunately back in 2017, iOS didn't have a proper machine learning framework. Core ML wasn't released yet and the only way to have a machine learning framework running on iOS is to have C/Objective C bindings pointing to actual Caffe C code. Most people ended just using remote web API to do their machine learning logic. However I wanted something local to the iPhone. Without the need of an Internet connection. So I needed to make iPhones execute actual machine learning logic. At the time, it was challenging: iPhones' RAM were limited, no GPU or no dedicated chip acceleration were available, using only CPU was painfully slow, and compiling/porting C code from machine learning framework like Tensorflow or Caffe to iOS wasn't straightforward. Oddly, all of this wasn't the most difficult part of this project.

Collecting images from Google Images was.

It was hard for multiple reasons: You are getting blocked from scraping image search results super fast by Google, you needed then to buy proxies, find a way to rotate proxies in a cost effective way, buy some CAPTCHA solving services as you still get blocked and proxies are expensive, run a full browser like PhantomJS or headless Chrome to load the pages, glue all of this together somehow, and finally parse the HTML to extract the images you wanted from a layout that has variations and can change daily. It was a pain.

Sample of greasy food images extracted for calorie guessing

In these projects, 80% of my time ended up being spent on scraping and parsing Google Images. And maybe only 20% on actual machine learning model training, UI design of the actual apps, and iOS programming.

I thought there must be a better way! However there was not. You couldn't pay a service that does that for you. There was no simple scraping API for Google Images or even regular Google searches. That was upsetting. I decided to work on solving this and started building prototypes. And SerpApi was born!

Here's a screenshot of one of the very first versions:

Screenshot of an early version of SerpApi

We've grown a lot since then. However it's interesting to know that collecting text and images from Google search results in order to train machine learning models is actually still one of the main use cases of SerpApi!