使用 wget 下載時忽略「其他」網域?

使用 wget 下載時忽略「其他」網域?

我想抓取 www.website.com/XYZ 下的鏈接,並且只下載 www.website.com/ABC 下的鏈接。

我正在使用以下 wget 命令來獲取我想要的檔案:

wget  -I ABC -r -e robots=off --wait 0.25  http://www.website.com/XYZ

當我使用 wget 1.13.4 時,這非常有效。但問題是我必須在具有 wget 1.11 的伺服器上使用此命令,當我使用相同的命令時,它最終會下載其他網域,例如:

www.website.de 
www.website.it 
...

我怎樣才能避免這個問題?我嘗試使用

--exclude domains=www.website.de,www.website.it

但它不斷下載這些網域。

另請注意,我無法使用,--no-parent因為我想要的文件位於上層(我想要透過抓取 website.com/XYZ 下的連結來獲取 website.com/ABC 下的文件)。

有什麼提示嗎?

答案1

您可以嘗試--max-redirect 0或使用--domains example.com 相反的--exclude-domains example.com.

看:

  -D,  --domains=LIST              comma-separated list of accepted domains.
       --exclude-domains=LIST      comma-separated list of rejected domains.
       --follow-tags=LIST          comma-separated list of followed HTML tags.
       --ignore-tags=LIST          comma-separated list of ignored HTML tags.
  -np, --no-parent                 don't ascend to the parent directory.
  --max-redirect                   maximum redirections allowed per page.

答案2

這是錯誤的:

--exclude domains=www.website.de,www.website.it

正確的方法是:

--exclude-domains www.website.de,www.website.it

來自 wget 手冊頁:

--exclude-domains domain-list
      Specify the domains that are not to be followed.

相關內容