python - 从 URL 下载 python 3.6.5 ftputil
问题描述
我有一个 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)
解决方案
推荐阅读
- java - Selenium 项目:Eclipse 中的错误
- c# - 这个 ViewModel 可能有任何问题吗?
- f# - 具有可选内容的 FParsec 解析列表,无法继续使用下一个解析器
- swift - 如何允许泛型集合在 swift 中执行幕后转换
- javascript - 未捕获的类型错误:firebase.database 不是函数
- javascript - Moment js在格式化后返回无效日期
- sql - SQL Query 以逗号分隔获取 Json 内部的 Json 值
- javascript - 使用帖子而不是获取数据重定向到另一个页面
- python - 如何在 Pandas DataFrame 中冻结索引和列,同时在 Jupyter Notebook 中保持样式?
- ggplot2 - ggplot图例垂直和水平