#! /usr/bin/env python # The argument is a URL root # It will download root.a, root.b, etc. and append them # The program downloads the file in binary mode. # e.g. httpcat1.py http://rocky2.ess.washington.edu/data/raster/naip2006/Chelan/naip_1-1_1n_s_wa007_2006_1.sid # Version 1.0 hgreen@u.washington.edu oct 22, 2007 # based on version 1.0 of httpcat.py, but used one letter suffix instead of two # This would run out of memory (strangely) on gigabyte pieces, so it uses megabyte buffers. # I imagine that it will fail to run in some environments. import sys import string import urllib # We could make the 404 check more elegant with urllib2 url = sys.argv[1] fname = url[string.rfind(url,'/')+1:] # tail of the pathname print 'Downloading ',fname,'from',url print 'Be patient.' g=open(fname,'wb') httpok=1 n=0 while httpok: # Making http connections okay # let1 = string.lowercase[n / 26] let2 = string.lowercase[n % 26] try: f = urllib.urlopen(url+'.'+let2) print 'Reading part ',url+'.'+let2 nbufs=0 # diagnostic while 1: buffer=f.read(1048576) # megabyte buffer # print nbufs nbufs+=1 if buffer[:21] == '