gpt4 book ai didi

unix - wget拒绝仍然下载文件

转载 作者:行者123 更新时间:2023-12-03 14:45:43 25 4
gpt4 key购买 nike

我只想要文件夹结构,但我不知道如何使用 wget。相反,我正在使用这个:

wget -R pdf,css,gif,txt,png -np -r http://example.com



应该拒绝-R之后的所有文件,但在我看来wget仍然下载文件,然后将其删除。

有没有更好的方法来获取文件夹结构?

TTP request sent, awaiting response... 200 OK Length: 136796 (134K) [application/x-download] Saving to: “example.com/file.pdf”

100%[=====================================>] 136,796 853K/s in 0.2s

2012-10-03 03:51:41 (853 KB/s) - “example.com/file.pdf” saved [136796/136796]

Removing example.com/file.pdf since it should be rejected.



如果有人想知道这是给客户的,他们可以告诉我结构,但是因为他们的 IT 人员必须这样做,所以这很麻烦,所以我想自己得到它。

最佳答案

这似乎是wget旨在工作。执行递归下载时,仍会下载与拒绝列表匹配的非叶子文件,以便收集它们作为链接,然后将其删除。

从代码内注释( recur.c ):

Either --delete-after was specified, or we loaded this otherwise rejected (e.g. by -R) HTML file just so we could harvest its hyperlinks -- in either case, delete the local file.



我们在过去的项目中遇到过这种情况,我们必须镜像一个经过身份验证的站点和 wget。即使它打算拒绝这些 URL,也会不断地点击注销页面。我们找不到任何选项来更改 wget 的行为。 .

我们最终得到的解决方案是 download ,破解并构建我们自己的 wget 版本.对此可能有更优雅的方法,但我们使用的快速修复方法是将以下规则添加到 download_child_p() routine 的末尾(修改以符合您的要求):
  /* Extra rules */
if (match_tail(url, ".pdf", 0)) goto out;
if (match_tail(url, ".css", 0)) goto out;
if (match_tail(url, ".gif", 0)) goto out;
if (match_tail(url, ".txt", 0)) goto out;
if (match_tail(url, ".png", 0)) goto out;
/* --- end extra rules --- */

/* The URL has passed all the tests. It can be placed in the
download queue. */
DEBUGP (("Decided to load it.\n"));

return 1;

out:
DEBUGP (("Decided NOT to load it.\n"));

return 0;
}

关于unix - wget拒绝仍然下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12704197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com