【问题标题】:Download file with the name from last part of directory referred instead of real file name using wget or curl(Wget is prefered)使用 wget 或 curl 从引用目录的最后部分下载文件,而不是使用真实文件名(首选 Wget)
【发布时间】:2016-07-03 13:37:53
【问题描述】:

让我们说,

http://mobile.example.com/vid/flying-birds 是存在链接http://mobile.example.com/vid/22 的页面, 当我们点击这个链接时, 它重定向到 http://v-cdn-r.example.com/mp4/x/y/dfile.mp4?ir=880&int=06 并下载名为 dfile.mp4?ir=880&int=06 的文件。

我想要这个文件名 flying-birds(来自第一页 url)。我试过用 wget 函数来做这个,

--default-page=name

用命令

wget -r -l1 --default-page=name http://mobile.example.com/vid/flying-birds

但下载的文件名现在是 22(来自第二个链接)而不是我预期的 flying-birds

我有多个链接,每个链接都有不同的关键字 比flying-birds.简单,有很多目录 不同-不同的目录名。

【问题讨论】:

    标签: linux curl download command wget


    【解决方案1】:

    你可以试试这样的:

    wget -r -l1 -O $(basename http://mobile.example.com/vid/flying-birds) http://mobile.example.com/vid/flying-birds
    

    查看此帖子以获取How to wget a file with correct name when redirected?

    【讨论】:

    • 您的解决方案非常适合单个操作...但是如果 i have more than one links and each link has different keywords than **flying-birds.** in simple, there is lots of directory with different-different directory name. i.e. **flying-birds** varies for each directory
    猜你喜欢
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-04
    • 2015-02-20
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多