2008/05/27

Python Version of wget

據說是 Guido van Rossum 在 Python Cookbook 的例子。
import sys, urllib
def reporthook(*a): print a
for url in sys.argv[1:]:
i = url.rfind('/')
file = url[i+1:]
print url, "->", file
urllib.urlretrieve(url, file, reporthook)

1 comment:

Human said...

Very useful, I needed exactly this to make a cgi script.