简体   繁体   中英

I need to download the image from URL and save into the folder in python 3.7

It's working perfect on local machine but when I upload the same code into the AWS server, its downloading only 1kb of image and its not readable? I need the whole image from URL. Please let me know how to resolve this issue?

print('Download Starting...')

url = 'https://hotpoptoday.com/wp-content/uploads/2019/12/9062079d.jpg'

req = requests.get(url, stream=True)


with open("9062079d.jpg",'wb') as output_file:
    for chunk in req.iter_content(chunk_size=1025):
        if chunk:
            output_file.write(chunk)

print('Download Completed!!!')

Simply just use like that

urllib.urlretrieve(url_to_your_image, "folders_name/saved_image.jpg")

if you want to create the folder before saving

os.mkdir('folder_name')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM