【问题标题】:Shell script (mac): How to download files from a directory using wget and regular expression?Shell 脚本 (mac):如何使用 wget 和正则表达式从目录下载文件?
【发布时间】:2009-10-10 18:08:43
【问题描述】:

我正在尝试使用 wget 从 Web 文件夹下载图像 (.jpg)。我只想下载文件名中有特定句子的图像。这很好用

wget -r -nd -A .jpg http://www.examplewebsite.com/folder/

但我喜欢包含一个句子,例如。 “约翰”。我试过了

wget -r -nd -A .jpg '*john*' http://www.examplewebsite.com/folder/

没有成功。任何想法如何进行?这可以在 shell 脚本(bash shell)中实现吗?我使用的是 Mac OSX 10.6.1。

【问题讨论】:

  • 不再是服务器故障或超级用户
  • 你想要页面名称中包含 john 的所有页面,还是文本中包含 john 的所有页面。
  • 我想从该页面(或网络文件夹)下载文件名中包含“john”的文件。例如。 picture_of_john.jpg 和 johns_picture.jpg
  • 你好快速免费色情! Shahmir 是对的,因为它不是堆栈溢出问题,除非更改,否则可能会关闭。提示:询问有关执行此操作的 shell 脚本。附言如果没有您想要获取的图像列表,这将无法完成。

标签: bash image shell download wget


【解决方案1】:

我的答案取决于您是否可以从网络服务器获取目录列表。如果可以,您可以保存该 HTML 列表,提取链接,过滤链接列表以找到符合您的条件的链接,然后将过滤后的列表传递给 curl 或 wget。

如果您无法以这种方式获取列表,则需要以其他方式生成列表,这可能是手动的。 (我假设您对该服务器的唯一访问权限是通过 http。)

【讨论】:

    【解决方案2】:

    怎么样:

    wget -r -nd -A '*john*.jpg' http://www.examplewebsite.com/folder/
    

    来自男人:

    Note that if any of the wildcard characters, *, ?, [ or ], appear in an element of
    acclist or rejlist, it will be treated as a pattern, rather than a suffix.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-25
      • 1970-01-01
      • 2010-12-10
      • 2013-08-17
      相关资源
      最近更新 更多