首页 > 解决方案 > 使用 wget 递归获取 .php 文件中的 .txt 文件,但过滤器会破坏命令

问题描述

我希望使用Bash shell从Salk Arabidopsis 1001 Genomes 站点quality_variant_[accession_name].txt下载所有文件。wget

运行下面的命令,最终输出感兴趣的文件(但由于 --spider 参数而没有下载),证明wget可以通过页面的超链接移动到我想要的文件。

wget --spider --recursive "http://signal.salk.edu/atg1001/download.php

我没有让命令运行足够长的时间来确定是否下载了感兴趣的文件,但是下面的命令确实开始递归下载站点。

# Arguments in brackets do not impact the performance of the command
wget -r [-e robots=off] [-m] [-np] [-nd] "http://signal.salk.edu/atg1001/download.php"

但是,每当我尝试应用过滤器来提取.txt感兴趣的文件时,无论是使用--accept-regex--accept还是许多其他变体,我都无法通过初始.php文件。

# This and variants thereof do not work
wget -r -A "quality_variant_*.txt" "http://signal.salk.edu/atg1001/download.php"

# Returns: 
# Saving to: ‘signal.salk.edu/atg1001/download.php.tmp’
# Removing signal.salk.edu/atg1001/download.php.tmp since it should be rejected.

我可以列出加入名称并循环访问这些名称以修改 wget 命令中的 URL,但我希望有一个动态的单行代码,即使随着时间的推移添加加入 ID,也可以提取所有感兴趣的文件。

谢谢!


注意:感兴趣的数据文件包含在目录中http://signal.salk.edu/atg1001/data/Salk/,该目录.php也是访问该 URL 时显示的静态 HTML 页面的主页。此 URL 不能在 wget 命令中使用,因为虽然感兴趣的数据文件包含在服务器端,但 HTML 页面不包含对这些文件的引用,而是链​​接到.txt我不想要的一组不同的文件。

标签: wget

解决方案


推荐阅读