开发者

Downloading files using Python

开发者 https://www.devze.com 2023-01-07 10:58 出处:网络
I need to download files from the internet. For that开发者_StackOverflow I am using subprocess and calling wget. Is this the right way? The files are hosted on static links and there is no need to log

I need to download files from the internet. For that开发者_StackOverflow I am using subprocess and calling wget. Is this the right way? The files are hosted on static links and there is no need to log in or anything.

I glanced over urllib but I could not find any example of it being used to download files of other types.

Any suggestions?


Other than what?

urllib.urlretrieve(url)

should work fine for any filetype. You will often want to specify a filename, rather than use a temp file (the default):

urllib.urlretrieve(url, filename)

There are several other libraries too, but this is fine for basic uses.

0

精彩评论

暂无评论...
验证码 换一张
取 消