使用 wget 限製文件

使用 wget 限製文件

我正在嘗試下載郵件清單檔案,例如

http://cryolist.org/archives/

特別是,我有一個頁面,並且想下載從該頁面連結的以“.txt.gz”結尾的每個檔案。有沒有辦法限制 wget 這樣做?如果失敗,還有替代方法嗎?

參考

http://www.gnu.org/software/wget/manual/html_node/

答案1

嘗試這個:

wget \
    --遞迴\
    --無目錄\
    --無父\
    - 1級 \
    --接受.txt.gz \
    --執行機器人=關閉\
    http://lists.cryolist.org/pipermail/cryolist-cryolist.org/

使用長選項以提高可讀性。

答案2

wget --help

-r,  --recursive          specify recursive download.
-l,  --level=NUMBER       maximum recursion depth (inf or 0 for infinite).
-A,  --accept=LIST        comma-separated list of accepted extensions.

請記住,文件連結到 iFrame 中列表.cryolist.org/pipermail/cryolist-cryolist.org,以下命令將產生所需的結果:

wget -r -l1 -A "txt.gz" lists.cryolist.org/pipermail/cryolist-cryolist.org

開關

  • -r開關可以下載連結到的其他資源。

  • 開關-l1將此限制為一級,即如果page1連結到page2page2連結到unwanted.txt.gz,則不會下載該檔案。

答案3

編寫一個 bash 腳本,將所有月份儲存在一個陣列中,循環遍歷它們,將它們插入到 wget 命令的正確位置

相關內容