I have a task to download Gbs of data from a website. The data is in form of .gz files, each file being 45mb in size.
The easy way to get the files is use "wget -r -np -A files url". This will donwload data in a recursive format and mirrors the website. The donwload rate is very high 4mb/sec.
But, just to play around I was also using python to build my urlparser.
Downloading via Python's urlretrieve is damm slow, possible 4 times as slow as wget. The download rate is 500kb/sec. I use HTMLParser for parsing the href tags.
I am not sure why is this happening. Are there any settings for this.
Thanks
You can use
wget -k
to engage relative links in all urls.Please show us some code. I'm pretty sure that it has to be with the code and not on urlretrieve.
I've worked with it in the past and never had any speed related issues.
Transfer speeds can be easily misleading.. Could you try with the following script, which simply downloads the same URL with both
wget
andurllib.urlretrieve
- run it a few times incase you're behind a proxy which caches the URL on the second attempt.For small files, wget will take slightly longer due to the external process' startup time, but for larger files that should be come irrelevant.
Since python suggests using
urllib2
instead ofurllib
, I take a test betweenurllib2.urlopen
andwget
.The result is, it takes nearly the same time for both of them to download the same file.Sometimes,
urllib2
performs even better.The advantage of
wget
lies in a dynamic progress bar to show the percent finished and the current download speed when transferring.The file size in my test is
5MB
.I haven't used any cache module in python and I am not aware of howwget
works when downloading big size file.