Here is a function that you can use in R. You'll first need to install.packages("rvest")
and install.packages("httr")
library(rvest)
library(httr)
get_first_google_image <- function(car_name)
{
site <- "https://www.google.com"
query <- paste0(site, "/search?q=", url_escape(car_name))
image_page <- read_html(query) %>%
html_nodes(xpath = "//a[contains(text(), 'Images')]") %>%
html_attr("href")
paste0(site, image_page) %>%
read_html(image_page) %>%
html_nodes("img") %>%
html_attr("src") %>%
{grep("gstatic", ., value = TRUE)} %>%
`[`(1) %>%
httr::GET() %>%
httr::content("raw") %>%
writeBin(paste0("~/", car_name, ".jpg"))
}
To use it, you just do
get_first_google_image("Mazda MX5")
It will then save the first hit from the Google image search as a jpeg to your home directory.
If you want to get all your car names into R, just select and copy the column in Excel then in R do
car_names <- readClipboard()
Then you can do
for(i in seq_along(car_names) get_first_google_image(car_names[i])
This might take quite a long time to run.