HI, everyone. I am new to Python and am using Python 2.5 on CentOS.
I need to download files like WGET
do.
I have done some search, and there are some solutions, an obvious way is this:
import urllib2
mp3file = urllib2.urlopen("http://www.example.com/songs/mp3.mp3")
output = open('test.mp3','wb')
output.write(mp3file.read())
output.close()
This works fine. But I want to know, if the mp3 file is VERY large, like 1Gb, 2Gb or even bigger. Can this code snippet still work? Are there better ways to download large files in Python, maybe with a progress bar like WGET
do.
Thanks a lot!
There's an easier way:
import urllib
urllib.urlretrieve("http://www.example.com/songs/mp3.mp3", "/home/download/mp3.mp3")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With