WGET 401 未经授权
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果网站只有一个 htpassword 设置,您可以尝试:
If the website has simply a htpassword setup, you can try:
我使用了
--auth-no-challenge
并解决了确切的错误。I used
--auth-no-challenge
and the exact error get solved .您的网络上有一个 Blue Coat 安全 Web 网关,如响应中的行所示:
它看起来像它希望您进行身份验证,大概使用您的域凭据。尝试使用
--http-user
和--http-passwd
传递它们。You have a Blue Coat secure web gateway on your network, as evidenced by the line in the response:
It looks like it wants you to authenticate, presumably with your domain credentials. Try passing them with
--http-user
and--http-passwd
.我在基于 xwiki 的网站上遇到了类似的问题。经过几次尝试,我发现一些对我来说效果很好的组合
我认为关键是 --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
I think the key was --auth-no-challenge
尝试使用 此 Firefox 扩展程序。它生成一个可以从 bash 复制并运行的
wget
或curl
命令。Try using this extension for firefox. It generates a
wget
or acurl
command that can be copied and run from bash.我来到这里试图找出为什么 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.
尝试使用 wget 设置用户代理字符串 - 例如,
站点完全可以拒绝来自某些用户代理的请求,特别是如果它们试图绕过“通常”的信息路由(即通过网页)。
尽管这不能解释您的问题,但无论如何这是一个好主意。也许该网站实施了一种机制,当您使用“已知”浏览器(例如 IE)浏览时,它会将您的 IP 缓存为“安全”,然后允许来自您 IP 的任何用户代理下载任何内容:)
Try setting a user-agent string with wget - e.g.
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 :)