0

次のコードを使用してファイルをダウンロードしています。

def downloadfile(url): #function to download file    
    file_name = filename_parse(url)
    #print "***********************"
    #print "File download started:"
    #stime= time.time()
    u = urllib2.urlopen(url)
    f = open(file_name, 'wb')
    getfilesize(u)
    file_size = getfilesize(u)
    print "Downloading: %s Bytes: %s \n" % (file_name, file_size)
    file_size_dl = 0
    block_sz = 512
    progressbar(u,block_sz,file_size_dl,f,file_size)
f.close()

問題は、.pdf ファイル以外の任意のファイル exe、txt などをダウンロードできるということです...どうすれば pdf をダウンロードできますか?

4

1 に答える 1