import urllib, os
def getweb(url, localdir):
usock = urllib.urlopen(url)
webdat=usock.read()
usock.close()
webdat=webdat[webdat.find("Parent Directory</a>"):]
allfile=webdat.split('href="')[1:]
for childurl in allfile:
childurl = childurl.split('"')[0]
print "process:", childurl
if(childurl[-1]=='/'):
localdir = childurl[:-1]
if not os.path.exists(localdir):
os.mkdir(localdir)
os.chdir(localdir)
getweb(url+childurl, localdir)
os.chdir("..")
else:
if os.path.exists(childurl): continue
usock = urllib.urlopen(url+childurl)
datsav = file(childurl, "wb+")
while True:
webdat=usock.read(10240)
if len(webdat)<=0: break
datsav.write(webdat)
usock.close()
datsav.close()
getweb("http://www.fon.hum.uva.nl/david/ma_ssp/2007/TIMIT/", "")
def getweb(url, localdir):
usock = urllib.urlopen(url)
webdat=usock.read()
usock.close()
webdat=webdat[webdat.find("Parent Directory</a>"):]
allfile=webdat.split('href="')[1:]
for childurl in allfile:
childurl = childurl.split('"')[0]
print "process:", childurl
if(childurl[-1]=='/'):
localdir = childurl[:-1]
if not os.path.exists(localdir):
os.mkdir(localdir)
os.chdir(localdir)
getweb(url+childurl, localdir)
os.chdir("..")
else:
if os.path.exists(childurl): continue
usock = urllib.urlopen(url+childurl)
datsav = file(childurl, "wb+")
while True:
webdat=usock.read(10240)
if len(webdat)<=0: break
datsav.write(webdat)
usock.close()
datsav.close()
getweb("http://www.fon.hum.uva.nl/david/ma_ssp/2007/TIMIT/", "")