已知图片或视频的URL,如何将其下载到本地

使用Python语言编写。

# 图片的URL
imgUrl = "https://p16-va-tiktok.ibyteimg.com/img/musically-maliva-obj/1645136815763462~c5_100x100.webp"
# 图片具体下载到的位置
downloadPath = "D://aaaaa/b.jpg"
img = requests.get(imgUrl).content

with open(downloadPath, 'wb') as data_file:
	data_file.write(img)

你可能感兴趣的:(通用)