1、需要的python库
requests
2、代码(复制可用)
#引用 requests文件
import requests
#下载地址
Download_addres='https://nj02cm01.baidupcs.com/file/da941ce26b392a4ea0b010b6e021a695?bkt=p3-1400da941ce26b392a4ea0b010b6e021a6956171262a00000003bca9&fid=3310494135-250528-127659779854873&time=1533574416&sign=FDTAXGERLQBHSK-DCb740ccc5511e5e8fedcff06b081203-KqPVE0es2sUR30U1G%2Fvps9I3VY4%3D&to=88&size=244905&sta_dx=244905&sta_cs=0&sta_ft=jpg&sta_ct=0&sta_mt=0&fm2=MH%2CQingdao%2CAnywhere%2C%2Cchongqing%2Ccmnet&resv0=cdnback&resv1=0&vuk=282335&iv=-2&newver=1&newfm=1&secfm=1&flow_ver=3&pkey=1400da941ce26b392a4ea0b010b6e021a6956171262a00000003bca9&sl=82640974&expires=8h&rt=sh&r=220567738&mlogid=445212826855757932&vbdid=1883780403&fin=1533574308687.jpg&fn=1533574308687.jpg&rtype=1&dp-logid=445212826855757932&dp-callid=0.1.1&hps=1&tsl=50&csl=78&csign=0vnYzTYv2VV%2Ff%2FRkrbacf8q2JPs%3D&so=0&ut=8&uter=4&serv=0&uc=1400105996&ic=321428139&ti=86348c5ac45f19b1da511678c3490bd3448fbb7a71823ad8&by=themis'
#把下载地址发送给requests模块
f=requests.get(Download_addres)
#下载文件
with open("12.ipg","wb") as code:
code.write(f.content)
3、注意
(1)下载地址不是网址,是下载地址,可以在QQ浏览器的点击下载,在下载窗口那里有个复制下载链接,用那个链接
(2)因为现在是单线程下载所有很慢,如果想要下载得很快的话,就要用多线程下载这样速度才会快,多线程的以后再写 (3)下载不同类型的文件一定要把后缀改了,不然会打不开,文件名是下载的文件名
with open("12.ipg","wb") as code:
12就是文件下下来的文件名
..jpg就是他的类型
因为现在这个是单线程嘛下载得很慢就用了一张图片下得比较快