【发布时间】:2017-07-05 13:47:28
【问题描述】:
我想下载大约 300 个项目的文件。下面是一个例子:
curl 'http://genome.jgi.doe.gov/ext-api/downloads/get-directory?organism=Absrep1' -b cookies > Absrep1.xml
这将打开页面并下载内容并将其存储为我的 xml 文件
我尝试使用系统命令在 perl 中执行批处理脚本,例如
system('curl 'http://genome.jgi.doe.gov/ext-api/downloads/get-directory?organism=Absrep1'
-b cookies > Absrep1.xml');
但是,它没有用。有语法错误,我猜这是由于单引号引起的。
我用python试过了,
import subprocess
bash_com = 'curl "http://genome.jgi.doe.gov/ext-api/downloads/get-directory?organism=Absrep1" '
subprocess.Popen(bash_com)
output = subprocess.check_output(['bash','-c', bash_com])
它没有工作。我收到错误,文件不存在。即使它有效,我怎样才能包含
-b cookie > Absrep1.xml'
参与其中?
请帮忙。提前致谢,
AP
【问题讨论】:
-
我刚刚发现,使用 os.system("curl 'genome.jgi.doe.gov/ext-api/downloads/…' -b cookies > Absrep1.xml") 更容易
标签: python-3.x perl subprocess