Mail from ILUG-BOM list (Non-Digest Mode)
Following Philip's presentation of his URL downloader, I decided
to see how quickly I could write a downloader tool in Python.
Half an hour of looking at the references later, I had this bit
of code:
--
#!/usr/bin/python
import urllib, sys
def downloadHook(blockCount, blockSize, totalSize):
if blockCount == 0:
if totalSize == -1:
print "Unknown file size."
else:
print "File Size:", totalSize, "bytes."
else:
print "\r", blockCount*blockSize, "bytes downloaded."
info = urllib.urlretrieve(sys.argv[1], sys.argv[2], downloadHook)
print "Headers:"
for x in info[1].keys():
print x+":", info[1][x]
--
Syntax is "urlget.py URL filename" where filename is the local
file to be saved and URL is in HTTP, FTP, Gopher or local file
syntax. Local is assumed if no protocol is specified.
This code is very rudimentary. I wrote this only 1) as proof of
possibility and 2) to learn some Python. This is only my second
bit of stand-alone Python code ever.
--
Kiran Jonnalagadda
http://lunateks.com
baby.sh: while true; do echo "^G^G^G^G^G"; sed -e 's/food/poop/';
sync; sync; sleep 15; done
_______________________________________________
Linuxers mailing list
[EMAIL PROTECTED]
http://ilug-bom.org.in/mailman/listinfo/linuxers