簡體   English   中英

可以使用 Wget 指定要下載的文件內容類型嗎?

[英]Can one specify a file content-type to download using Wget?

我想使用 wget 下載從網站主頁鏈接的文件,但我只想下載 text/html 文件。 是否可以根據 mime 內容類型將 wget 限制為文本/html 文件?

我認為他們還沒有實施這一點。 因為它仍然在錯誤列表中。

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=21148

您可能必須通過文件擴展名做所有事情

Wget2 有這個功能。

--filter-mime-type    Specify a list of mime types to be saved or ignored`

### `--filter-mime-type=list`

Specify a comma-separated list of MIME types that will be downloaded.  Elements of list may contain wildcards.
If a MIME type starts with the character '!' it won't be downloaded, this is useful when trying to download
something with exceptions. For example, download everything except images:

  wget2 -r https://<site>/<document> --filter-mime-type=*,\!image/*

It is also useful to download files that are compatible with an application of your system. For instance,
download every file that is compatible with LibreOffice Writer from a website using the recursive mode:

  wget2 -r https://<site>/<document> --filter-mime-type=$(sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/,/g' /usr/share/applications/libreoffice-writer.desktop)

Wget2 到今天還沒有發布,但很快就會發布。 Debian 不穩定版已經發布了 alpha 版本。

查看https://gitlab.com/gnuwget/wget2了解更多信息。 您可以將問題/評論直接發布到 bug-wget@gnu.org。

將 header 添加到選項中

wget --header 'Content-type: text/html'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM