1

我有一个 csv 文件,其中包含文件路径,例如:oa_package/08/e0/PMC13900.tar.gz、oa_package/b0/ac/PMC13901.tar.gz 等。

如果要在浏览器中键入 ftp.ncbi.nlm.nih.gov/pub/pmc/oa_package/08/e0/PMC13900.tar.gz ,它会自动下载文件,有没有办法复制这种行为Python?

以前,我已成功使用以下 try/catch 以及 host.listdir('.') 从同一目录迭代和下载文件。在这种情况下,我打算下载当前工作目录之外的文件。

host = ftputil.FTPHost('ftp.ncbi.nlm.nih.gov', 'anonymous', email)
path = "pub/pmc/"
host.chdir(path) #gets to ftp.ncbi.nlm.nih.gov/pub/pmc/

outFile = outDir + file
print("retrieving file:", file)  
try:         
    host.download(file, outFile) #file is zip file
except:
    print("WARNING: File could not be downloaded")

回溯错误是:

FTPOSError: [Errno 11001] getaddrinfo failed
Debugging info: ftputil 3.4, Python 3.6.5 (win32)
4

0 回答 0