GoogleScraper can scrape results from search engines. If you want to learn more about all of GoogleScraper capabilities, read it's description in the repository:GoogleScraper. In this tutorial we will use GoogleScrape programmatically by using the image search. The search keyword is beautiful landscape. We will scrape the first 5 pages of the image search results from the search engines:

  • yandex
  • google
  • bing
  • baidu
  • yahoo

and then we're going to download all images that we found, by using 100 threads :)

Furthermore, we are going to save the results in a CSV file for further inspection.

Whereas the scraping is done by GoogleScraper, the downloading logic is manual code that you can see below.

The code

All the above requirements are implemented in the following short code, which uses GoogleScraper.

First of course you need to install GoogleScraper, you can do so by reading How to install GoogleScraper

After having installed it, you should get a version at least

GoogleScraper --version

Then save and execute the following code in a fresh directory.

import threading,requests, os, urllib
from GoogleScraper import scrape_with_config, GoogleSearchError
from GoogleScraper.database import ScraperSearch, SERP, Link

target_directory = 'images/'

# See in the config.cfg file for possible values
config = {
    'SCRAPING': {
        'keyword': 'beautiful landscape',
        'search_engines': 'yandex,google,bing,baidu,yahoo',
        'search_type': 'image',
        'scrapemethod': 'selenium',
        'num_pages_for_keyword': '5',
        'output_format': 'csv',
        'output_filename': 'image_search'

    sqlalchemy_session = scrape_with_config(config)
except GoogleSearchError as e:

image_urls = []
search = sqlalchemy_session.query(ScraperSearch).all()[-1]

for serp in search.serps:
        [ for link in serp.links]

print('[i] Going to scrape {num} images and saving them in "{dir}"'.format(

class FetchResource(threading.Thread):
    """Grabs a web resource and stores it in the target directory"""
    def __init__(self, target, urls):
        super().__init__() = target
        self.urls = urls

    def run(self):
        for url in self.urls:
            url = urllib.parse.unquote(url)
            with open(os.path.join(, url.split('/')[-1]), 'wb') as f:
                    content = requests.get(url).content
                except Exception as e:
                print('[+] Fetched {}'.format(url))

# make a directory for the results
except FileExistsError:

# fire up 100 threads to get the images
num_threads = 100

threads = [FetchResource('images/', []) for i in range(num_threads)]

# spread the urls to fetch equally among the threads 
while image_urls:
    for t in threads:
        except IndexError as e:

threads = [t for t in threads if t.urls]

for t in threads:

for t in threads:

# that's it :)

Now run the scripts. It will need a little time. Then you'll have all results in a filename image_search.csv in the same directory where you started the script :)

Also: The above code will download all found images with 100 threads. This will also consume some moments ;)

You'll find the images in the images/ directory.

The results

If you insist on the results, here are they:,xcitefun-beautiful-landscape-lovely-images-3.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg*qV78jfZRkfEAo2j-FY0cegEYjnPVVJdWVFf7jLoR2xXJl7-Jyza1auzc3IlGxme0SsAm/Landscapes.4.bmp,-naves,-agua,-nubes,-hdr-177416.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg*qV78jfZRkfEAo2j-FY0cegEYjnPVVJdWVFf7jLoR2xXJl7-Jyza1auzc3IlGxme0SsAm/Landscapes.4.bmp,-naves,-agua,-nubes,-hdr-177416.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg,xcitefun-beautiful-landscape-lovely-images-13.jpg,xcitefun-beautiful-landscape-lovely-images-3.jpg*qV78jfZRkfEAo2j-FY0cegEYjnPVVJdWVFf7jLoR2xXJl7-Jyza1auzc3IlGxme0SsAm/Landscapes.4.bmp*qV78jfZRkfEAo2j-FY0cegEYjnPVVJdWVFf7jLoR2xXJl7-Jyza1auzc3IlGxme0SsAm/Landscapes.4.bmp*qV78jfZRkfEAo2j-FY0cegEYjnPVVJdWVFf7jLoR2xXJl7-Jyza1auzc3IlGxme0SsAm/Landscapes.4.bmp