python request+open任意のファイルをダウンロード


インスタンスソース
    link = 'https://www.google.com.au/url?sa=i&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwiaucyRvurcAhVaMt4KHbRMCOcQjRx6BAgBEAU&url=https%3A%2F%2Fimage.so.com%2F&psig=AOvVaw3u3MRzkFwBIJglN_Ir-Wy0&ust=1534265396809360'

    #    :    
    img_response = requests.get(link)

    #    :    
    filename = str(uuid.uuid4()) + '.jpg'

    #    :    
    with open(filename,'wb') as f:
        f.write(img_response.content)