wget批量下载设置文件名

时间:2020-07-09 15:28:51

标签: python bash wget

我正在尝试使用输入文件(wget -i a.txt )下载文件,该文件的URL使用以下命令

https://domian.com/abc?api=123&xyz=323&title=newFile12
https://domian.com/abc?api=1243&xyz=3223&title=newFile13

URL就像

newFile12

我想通过使用标题标签从URL中设置文件的名称(例如,在上面的URL中,文件下载的名称必须为{{1}}),但找不到任何解决方法

为了完成它,我必须编写一个python脚本(类似于此答案https://stackoverflow.com/a/28313383/10549469),然后以其他方式逐个运行。

2 个答案:

答案 0 :(得分:1)

您可以即时创建脚本并将其通过管道传递给bash。比def draw_everything(dt): # draw stuff here @window.event def on_draw(): draw_everything(None) pyglet.clock.schedule_interval(draw_everything, 1/60) 慢一点,但会保留文件名:

wget -i

对结果感到满意时,可以将其通过管道传输到bash:

 sed "s/\(.*title=\(.*\)\)/wget -O '\2' '\1'/" a.txt

答案 1 :(得分:-1)

看看wget --content-disposition或与wget -O <outputfile name> <url>进行循环

以下命令将下载服务器(vim-readonly-1.1.tar.gz提供的文件名而不是download_script.php?src_id=27233的文件。

wget --content-disposition https://www.vim.org/scripts/download_script.php?src_id=27233
相关问题