def getFile(link):
try:
source = urllib2.urlopen(link)
except(urllib2.HTTPError),msg:
print "\nError:",msg
sys.exit()
num = 1
file = 'tmp_insidepropw_'+link.split('=')[1]+'.txt'
while os.path.isfile(file) == True:
file = link.rsplit("/",1)[1]+"."+str(num)
num+=1
try:
shutil.copyfileobj(source, open(file, "w+"))
except(IOError):
print "\nCannot write to `"+file+"' (Permission denied)."
sys.exit(1)
print "File downloaded", file
newfilelist.append(file)
评论列表
文章目录