[英]I need to download the image from URL and save into the folder in python 3.7
它在本地機器上運行良好,但是當我將相同的代碼上傳到 AWS 服務器時,它只下載 1kb 的圖像並且不可讀? 我需要來自 URL 的整個圖像。 請讓我知道如何解決這個問題?
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!!!')
只需像那樣使用
urllib.urlretrieve(url_to_your_image, "folders_name/saved_image.jpg")
如果要在保存之前創建文件夾
os.mkdir('folder_name')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.