我有 52 个文件需要检索和下载,但是,我已经开始手动输入网址。我很好奇我是否可以在网络服务器中找到所有文件并直接下载它们,或者遍历网址并打开它们。
URL 格式如下:
http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/a/a_gs_1.jpg
其中 'a' 是字母表中的字母,数字是否大写。
例如:
/english_alphabet/c/c_gs_1.jpg 将是大写的“C”
/english_alphabet/d/d_gs_2.jpg 将是小写的“d”
我希望这能使大家理解我的观点。
我不想像这样手动输入它们,而是想通过网络服务器查找这些文件,或者遍历组合然后打开选项卡。有什么想法吗?这比手动输入 52 个 URL 更节省时间 :p 谢谢!
答案1
在 Linux 下使用 bash,或在 Windows 下使用赛格威或使用在 Windows 上运行的原生 bash shell,您可以使用bash 扩展。
例如编写echo {a..z}
你的 shell 将会扩展它
a b c d e f g h i j k l m n o p q r s t u v w x y z
因此,您可以使用 for 循环进行迭代并下载生成的每个单个 url。下面是脚本示例和一行命令。
BaseUrl="http://www.loopsandtails.com/wp-content/themes/LoopsAndTails"
for i in {a..z}
do
# here below for each $i it will see a, b, c ... z
wget ${BaseUrl}/english_alphabet/${i}/${i}_gs_1.jpg
done
注意:我将 URL 存储在变量 BaseUrl 中,以使上面的脚本更易于阅读。
你可以直接在一行中写入
for i in {a..z} ; do wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/${i}/${i}_gs_1.jpg ; done
笔记:
- 我认为您有权从该网站下载(您必须始终检查每个网站的版权)。
- 您始终可以使用
wget
下载整个子目录,将下载限制为具有指定钥匙在名称中。检查帮助和能力获得。
在 powershell 下,您可以使用相应的语法编写类似于上面的脚本。
答案2
在文本编辑器中通过剪切和粘贴来强制编辑脚本可能比通过编程编写脚本需要更少的按键
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/a/a_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/b/b_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/c/c_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/d/d_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/e/e_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/f/f_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/g/g_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/h/h_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/i/i_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/j/j_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/k/k_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/l/l_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/m/m_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/n/n_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/o/o_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/p/p_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/q/q_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/r/r_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/s/s_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/t/t_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/u/u_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/v/v_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/w/w_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/x/x_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/y/y_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/z/z_gs_1.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/a/a_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/b/b_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/c/c_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/d/d_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/e/e_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/f/f_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/g/g_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/h/h_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/i/i_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/j/j_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/k/k_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/l/l_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/m/m_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/n/n_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/o/o_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/p/p_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/q/q_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/r/r_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/s/s_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/t/t_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/u/u_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/v/v_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/w/w_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/x/x_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/y/y_gs_2.jpg
wget http://www.loopsandtails.com/wp-content/themes/LoopsAndTails/english_alphabet/z/z_gs_2.jpg