Python - 从 url 保存图像
有没有办法使用 urllib 或 Beautiful Soup 保存 url 中的图片?
-谢谢
Is there a way to save a picture from a url using urllib or Beautiful Soup?
-Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要
urllib.urlretrieve()
。You want
urllib.urlretrieve()
.不需要美丽的汤,因为我假设你需要读取二进制文件。
只需读取流并将其存储为文件即可。
顺便提一句。为了解决多千兆位图像的问题,
第二个代码片段将更加可靠。感谢
Ignacio Vazquez-Abrams
启发了大文件的问题。no need of Beautiful Soup as i assume you need to read a binary file.
Just read the stream and store it as a file.
btw. to address the issue of multigigabit images
2nd code snippet gonna be more reliable.. thanks to
Ignacio Vazquez-Abrams
enlighten this issue of large files.只是为自己写的。
Just wrote this for myself.
只需在读取数据时写入文件即可。
Simply write to a file while reading the data.