WGET 401 未经授权

发布于 2025-01-03 22:58:16 字数 2158 浏览 7 评论 0原文

我正在尝试使用 WGET 的批处理文件从此处下载公共 FCC 文件

http://wireless.fcc.gov/uls/data/complete/l_micro.zip

当我最初使用参数运行批处理文件时,

wget --server-response -owget.log http://wireless.fcc.gov/uls/data/complete/l_micro.zip 

它失败并出现 HTTP 401 未经授权的错误。我现在可以重试,但它一直失败。但是我注意到,如果我打开 IE,开始下载并在提示保存时取消,我可以重新运行批处理文件并且它可以完美执行!

这是我从日志中获得的详细服务器响应

--2012-02-06 14:32:24--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: REMOVED - appears to have my IP
  Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: text/html; charset=utf-8
  Connection: close
  Content-Length: 513
Location: REMOVED [following]
--2012-02-06 14:32:24--  REMOVED
Resolving REMOVED... 192.168.2.11
Connecting to REMOVED|192.168.2.11|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 401 Unauthorized
  Cache-Control: no-cache
  Pragma: no-cache
  WWW-Authenticate: NTLM
  WWW-Authenticate: BASIC realm="AD_BCAAA"
  Content-Type: text/html; charset=utf-8
  Proxy-Connection: close
  Set-Cookie: BCSI-CS-8ECFB6B4AA642EF0=2; Path=/
  Connection: close
  Content-Length: 575
Authorization failed.

这是执行我的小 IE 程序并使其正常工作后的日志

--2012-02-08 15:52:43--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Server: Sun-Java-System-Web-Server/7.0
  Date: Fri, 27 Jan 2012 18:37:51 GMT
  Content-type: application/zip
  Last-modified: Sun, 22 Jan 2012 11:18:09 GMT
  Etag: "46fa95c-4f1bf071"
  Accept-ranges: bytes
  Content-length: 74426716
  Connection: Keep-Alive
  Age: 1045014
Length: 74426716 (71M) [application/zip]
Saving to: `l_micro.zip'

任何帮助都将不胜感激!

I'm trying to use a batch file with WGET to download the public FCC file from here

http://wireless.fcc.gov/uls/data/complete/l_micro.zip

When I intially run the batch file with parameters

wget --server-response -owget.log http://wireless.fcc.gov/uls/data/complete/l_micro.zip 

It fails with an HTTP 401 unauthorized error. I can retry at this point and it keeps failing. However I noticed if I open up IE, start a download and cancel when prompted to save, I can rerun the batch file and it executes perfectly!

Here is my detailed server response from the log

--2012-02-06 14:32:24--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: REMOVED - appears to have my IP
  Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: text/html; charset=utf-8
  Connection: close
  Content-Length: 513
Location: REMOVED [following]
--2012-02-06 14:32:24--  REMOVED
Resolving REMOVED... 192.168.2.11
Connecting to REMOVED|192.168.2.11|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 401 Unauthorized
  Cache-Control: no-cache
  Pragma: no-cache
  WWW-Authenticate: NTLM
  WWW-Authenticate: BASIC realm="AD_BCAAA"
  Content-Type: text/html; charset=utf-8
  Proxy-Connection: close
  Set-Cookie: BCSI-CS-8ECFB6B4AA642EF0=2; Path=/
  Connection: close
  Content-Length: 575
Authorization failed.

Here is the log after doing my little IE procedure and getting it to work

--2012-02-08 15:52:43--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Server: Sun-Java-System-Web-Server/7.0
  Date: Fri, 27 Jan 2012 18:37:51 GMT
  Content-type: application/zip
  Last-modified: Sun, 22 Jan 2012 11:18:09 GMT
  Etag: "46fa95c-4f1bf071"
  Accept-ranges: bytes
  Content-length: 74426716
  Connection: Keep-Alive
  Age: 1045014
Length: 74426716 (71M) [application/zip]
Saving to: `l_micro.zip'

Any help is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

三生一梦 2025-01-10 22:58:16

如果网站只有一个 htpassword 设置,您可以尝试:

wget --user=admin --ask-password https://www.yourwebsite.com/file.zip

If the website has simply a htpassword setup, you can try:

wget --user=admin --ask-password https://www.yourwebsite.com/file.zip
说好的呢 2025-01-10 22:58:16

我使用了 --auth-no-challenge 并解决了确切的错误。

I used --auth-no-challenge and the exact error get solved .

﹏半生如梦愿梦如真 2025-01-10 22:58:16

您的网络上有一个 Blue Coat 安全 Web 网关,如响应中的行所示:

Set-Cookie: BCSI-CS-8ECFB6B4AA642EF0=2; Path=/

它看起来像它希望您进行身份验证,大概使用您的域凭据。尝试使用 --http-user--http-passwd 传递它们。

You have a Blue Coat secure web gateway on your network, as evidenced by the line in the response:

Set-Cookie: BCSI-CS-8ECFB6B4AA642EF0=2; Path=/

It looks like it wants you to authenticate, presumably with your domain credentials. Try passing them with --http-user and --http-passwd.

蓝天白云 2025-01-10 22:58:16

我在基于 xwiki 的网站上遇到了类似的问题。经过几次尝试,我发现一些对我来说效果很好的组合

wget --no-check-certificate --auth-no-challenge -k -nc -p -l 1 -r https://用户:[电子邮件受保护]

我认为关键是 --auth-no-challenge

I had a similar issue with the xwiki based site. after several attempts I found some combination that worked for me just fine

wget --no-check-certificate --auth-no-challenge -k -nc -p -l 1 -r https://user:[email protected]

I think the key was --auth-no-challenge

油焖大侠 2025-01-10 22:58:16

尝试使用 Firefox 扩展程序。它生成一个可以从 bash 复制并运行的 wgetcurl 命令。

Try using this extension for firefox. It generates a wget or a curl command that can be copied and run from bash.

怕倦 2025-01-10 22:58:16

我来到这里试图找出为什么 wget 给出 401 未经授权的消息,而在另一个系统上没有出现问题。

从源代码安装更高版本的 wget 后(二进制文件在我的发行版中不可用),它起作用了。我无法解释为什么,除了它一定是某种错误,所以如果上述方法都不能解决您的问题,请考虑升级 wget。

I came here trying to find out why wget was giving a 401 unauthorized message when on another system the problem did not occur.

After installing a later version of wget from source (binary was not available in my distro) it worked. I can't explain why, except that it must be some kind of bug so if none of the above fixes your problem, consider upgrading wget.

倾`听者〃 2025-01-10 22:58:16

尝试使用 wget 设置用户代理字符串 - 例如,

--user-agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)  

站点完全可以拒绝来自某些用户代理的请求,特别是如果它们试图绕过“通常”的信息路由(即通过网页)。

尽管这不能解释您的问题,但无论如何这是一个好主意。也许该网站实施了一种机制,当您使用“已知”浏览器(例如 IE)浏览时,它会将您的 IP 缓存为“安全”,然后允许来自您 IP 的任何用户代理下载任何内容:)

Try setting a user-agent string with wget - e.g.

--user-agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)  

it's entirely feasible for a site to reject requests from certain user agents, particularly if they look to be circumventing the "usual" routes to information (i.e. through webpages).

Although this doesn't explain your problem, it's a good idea anyway. Perhaps the site implements a mechanism whereby when you browse with a "known" browser (e.g. IE) it then caches your IP as "safe" then allows any user agent from your IP to download anything :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文