downloadlist=bsobj.findAll(src=True)
downloadlist就是要下载的图片的集合。
然后fileURL就是图片的URL了,
for download in downloadlist:
fileURL=getabsoluteurl(baseURL,download["src"])
print(fileURL)
if fileURL is not None:
urlretrieve(fileURL,getdownloadpath(fileURL,downloadDirectory),cbk)
下面就是报错原因:
//ossweb-img.qq.com/images/lol/v3/logo.png
Traceback (most recent call last):
File "C:/Users/18022863809/Desktop/python_work/文件下载.py", line 44, in <module>
urlretrieve(fileURL,getdownloadpath(a,downloadDirectory),cbk)
File "C:/Users/18022863809/Desktop/python_work/文件下载.py", line 29, in getdownloadpath
os.makedirs(directory)
File "C:\Users\18022863809\AppData\Local\Programs\Python\Python37\lib\os.py", line 211, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\18022863809\AppData\Local\Programs\Python\Python37\lib\os.py", line 211, in makedirs
makedirs(head, exist_ok=exist_ok)
File "C:\Users\18022863809\AppData\Local\Programs\Python\Python37\lib\os.py", line 221, in makedirs
mkdir(name, mode)
FileNotFoundError: [WinError 53] 找不到网络路径。: '//ossweb-img.qq.com/images/'
上面就是报错原因,非常奇怪,我直接在浏览器复制这个URL能够访问,为什么这里找不到网络路径呢