这段代码对我有用。我只是对其进行了一点修改,因为您正在复制每个ppt文件。
from urllib2 import urlopenimport reurlpath =urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/')string = urlpath.read().depre('utf-8')pattern = re.compile('ch[0-9]*.ppt"') #the pattern actually creates duplicates in the listfilelist = pattern.findall(string)print(filelist)for filename in filelist: filename=filename[:-1] remotefile = urlopen('http://www.divms.uiowa.edu/~jni/courses/ProgrammignInCobol/presentation/' + filename) localfile = open(filename,'wb') localfile.write(remotefile.read()) localfile.close() remotefile.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)