使用Python从网站下载文件 [英] Download Files from a Website with Python

查看:63
本文介绍了使用Python从网站下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从网站上下载大约300个小文件。全部位于一个目录中。文件大小不同,扩展名也不同。我不想在网络浏览器中键入每个,然后单击另存为等等。我想将清单提供给python,并下载并保存每个文件到目录中。如果python可以简单地下载目录,那就更好了。

I have about 300 small files that I need to download from a website. All are located in one directory. The files are of different sizes and have different extensions. I don't want to type each one into my web browser and then click 'save as' and such. I want to give my list to python and have it download and save each file in a directory. If python can simply download the directory, that would be even better.

推荐答案

所有这些此处。我希望使用Requests,因为它通常很棒,但是urllib2在标准库中,因此不需要安装新的软件包。

This is all detailed here. I would favor using Requests as it's generally great, but urllib2 is in the standard library so doesn't require the installation of a new package.

这篇关于使用Python从网站下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆