arrrlo / Google-Images-Search

[PYTHON] Search for image using Google Custom Search API and resize & crop afterwards
MIT License
178 stars 34 forks source link

No Results #139

Closed krypterro closed 2 years ago

krypterro commented 2 years ago

I can't seem to get any image results, but no errors either. Running Python 3.8.10 on Linux Mint, with a fresh venv.


from google_images_search import GoogleImagesSearch

def main():
  key = "AIzaSyxxxxxxxxxxxxxxxxxxxxq8W9TpSedhHeY"
  cx = "0016904xxxxxxxx366:n-vrnapnina"
  gis = GoogleImagesSearch(key, cx)

  search_params = {
    'q': 'superman',
    'num': 10,
    #'fileType': 'jpg',
    #'rights': 'cc_publicdomain',
    #'safe': 'off', ##
    #'imgType': 'imgTypeUndefined', ##
    #'imgSize': 'imgSizeUndefined', ##
  }

  gis.search(search_params=search_params)

  print(gis.results())

  for image in gis.results():
      print("*")
      image.url
      image.referrer_url
      image.download('covers/')
      image.resize(300, 300)
      image.path

main()
arrrlo commented 2 years ago

Hi,

My first guess is that you misconfigured your custom search project.

Visit https://cse.google.com/cse/all and in the web form where you create/edit your custom search engine enable "Image search" option and for "Sites to search" option select "Search the entire web but emphasize included sites".

krypterro commented 2 years ago

Right you were, thank you.

nebula1989 commented 2 years ago

Amazing! I had the same issue. Thank you Arrrlo.