# KEHOME/src/pyget.py
# Apr/28/2003
# copy url to local file
# usage: pyget.py url >file

# adapted from program by Steve Hunter

import sys	# for .argv
import urllib

def geturl(url):
    f = urllib.urlopen(url); data = f.read(); headers = f.info(); f.close() 

    if headers.has_key("content-type"): mimetype = headers["content-type"] 
    elif url.endswith(".html"): mimetype = "text/html" 
    else: mimetype = "application/octet-stream"

    return (data, mimetype) 

sys.argv.pop(0) # toss the name of this pgm

for url in sys.argv: s, mimetype = geturl(url); print url, "\n", mimetype, "\n\n", s

