Python program that emulates the wget linux command. This program allows continue or resume a download where it failed or was interrupted.
This program is not intended to be used in a production system. It aims to show how resuming downloads works.
- requirements
- clone this repo
- usage
- Python 2.7 is required to run the code
$ git clone https://github.com/imarban/pget.git
$ cd pget
$ python client.py <url>
Replace for the actual url you want to download. You will get the file downloaded to the current path.
The program accept some parameters at the invoking time
- -c --continue If you are trying to continue a download which was interrupted you need to set this flag. If you don't use this flag the previous download attempts for the same resource are going to be deleted.
- -o --outfile If this argument is passed, the name of the file where the download content is written is going to be changed. If this parameter is absent the file name will be extracted from the url last part.
- -v --verbose. It sets the logger level to DEBUG for seeing more information.
$ python client.py <url> -c -o <filename.extension> -v
You will get the file downloaded to the current path
The next are some resources that were useful at the time I was writing this program:
- http://www.thinkbroadband.com/download.html Download test files
- http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html Range HTTP header
- https://docs.python.org/2/library/urllib2.html How to make a request in HTTP with Python