How to Scrape Images from Google

[This article was first published on Florian Teschner, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In my last post, I tried to train a deep neural net to detect brand logos in images. For that, I downloaded the Flickr27-dataset, containing 270 images of 27 different brands. As this dataset is rather small I turned to google image search and wrote a small R script to download the first 20 images for each search term.

In order to use the script you need to download phantomJS and create a small Javascript file. (See the Gist-file at the end of this post.) If you have the phantomJS.exe, the small JS-file and the R-file in one folder, you just need to run the following lines to download the images …

gg <- scrapeJSSite(searchTerm = "adidas+logo")
downloadImages(as.character(gg$images), i)

exampleLogos

Good luck scraping some images from Google. I will use the script to enhance the brand logo dataset, hopefully improving my model with some better image data.

To leave a comment for the author, please follow the link and comment on their blog: Florian Teschner.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)