본문 바로가기
프로그래밍언어/Python

파이썬 구글 이미지 크롤링

by plog 2019. 12. 11.

 

google_images_download  

파이썬은 다양한 라이브러리를 통해 웹 페이지에 넘쳐나는 이미지들을 크롤링 수행할 수 있도록 도와줍니다.
google_images_download 예제입니다.

# 참고: https://google-images-download.readthedocs.io/en/latest/examples.html
# pip install google_images_download
from google_images_download import google_images_download   

def ImageCrawling(keyword, dir):
    response = google_images_download.googleimagesdownload()  

    arguments = {"keywords":keyword # 키워드
        ,"limit":50 # 이미지 크롤링 수
        ,"print_urls":True # 출력 여부
        ,'output_directory':dir}   #이미지 저장 장소
    paths = response.download(arguments)   #passing the arguments to the function
    print(paths)   #printing absolute paths of the downloaded images

# 여러 검색어 검색:'Polar bears,baloons,Beaches'  꼼마로 구분 된다. 각각 폴더로 생성
ImageCrawling('오재원','d:/lg/')

 

댓글