已经爬去到图片的URL,测试输出成功,如何才能把图片下载到本地?
方法一:
结果是
方法二:
结果是
新手求解,希望大神指出错误,给出改正方法,谢谢
PHP中文网2017-04-18 09:25:36
The open function opens a file. The question is, it is a directory.
1 2 3 4 |
|
Just add the file name.
迷茫2017-04-18 09:25:36
1 2 3 4 5 6 7 8 9 |
|
Obviously the file name was not included when writing
PHP中文网2017-04-18 09:25:36
There is no downloaded file name...
1 2 3 4 5 6 7 8 |
|
伊谢尔伦2017-04-18 09:25:36
Don’t use Chinese for the folder path, try changing it to an English path
高洛峰2017-04-18 09:25:36
Please confirm whether writing a file directly using python can be successful. The error is caused by permissions.
Replace the double quotes in the directory path with single quotes
PHP中文网2017-04-18 09:25:36
If there are Chinese characters in the path name, it is recommended to use Unicode format so that there will be no recognition errors
迷茫2017-04-18 09:25:36
urllib.request.urlretrieve(url, filename=None, reporthook=None, data=None)
This function. Simple and practical. It’s better to add exception handling