Downloading files using Python
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.
精彩评论