Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from google_images_search import GoogleImagesSearch
- # Google-Images-Search
- # https://pypi.org/project/Google-Images-Search/
- # you can provide API key and CX using arguments,
- # or you can set environment variables: GCS_DEVELOPER_KEY, GCS_CX
- gis = GoogleImagesSearch('Your GCS_DEVELOPER_KEY goes here', 'Your GCS_CX goes here')
- search_q = 'Disney princess'
- # define search params:
- _search_params = {
- 'q': search_q,
- 'num': 200, #usually a higher number will not yield more good results, better run again with a different search_q
- 'safe': 'off',
- 'fileType': 'jpg',
- #'imgType': 'clipart|face|lineart|news|photo',
- #'imgType': 'face', #useful for FFHQ transfer-learning
- 'imgType': 'face',
- #'imgSize': ' "['imgSizeUndefined', 'HUGE', 'ICON', 'LARGE', 'MEDIUM', 'SMALL', 'XLARGE', 'XXLARGE']"',
- 'imgSize': 'XLARGE',
- #'imgDominantColor': 'black|blue|brown|gray|green|pink|purple|teal|white|yellow',
- #'rights': 'cc_publicdomain|cc_attribute|cc_sharealike|cc_noncommercial|cc_nonderived'
- }
- # this will only search for images:
- #gis.search(search_params=_search_params)
- # this will search and download:
- try:
- gis.search(search_params=_search_params, path_to_dir='./gimages/', custom_image_name=search_q.replace(' ', '_'))
- except:
- print("Okay, bye now")
Add Comment
Please, Sign In to add comment