不工作

时间:2012-06-15 22:11:44

标签: ubuntu

在Ubuntu上,我正在尝试使用wget下载文件(从脚本中)。 构建程序以每天下载此文件并加载到hadoop集群。

但是,wget失败,并显示以下消息。

wget http://www.nseindia.com/content/historical/EQUITIES/2012/JUN/cm15JUN2012bhav.csv.zip
--2012-06-16 03:37:30--  http://www.nseindia.com/content/historical/EQUITIES/2012/JUN/cm15JUN2012bhav.csv.zip
Resolving www.nseindia.com... 122.178.225.48, 122.178.225.18
Connecting to www.nseindia.com|122.178.225.48|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2012-06-16 03:37:30 ERROR 403: Forbidden.

当我在firefox或同等版本中尝试相同的网址时,它的工作正常。是的,没有涉及许可协议的事情......

我错过了关于wget的基本内容吗?

5 个答案:

答案 0 :(得分:12)

网站阻止wget,因为wget默认使用不常见的用户代理。要在wget中使用其他用户代理,请尝试:

wget -U Mozilla/5.0 http://www.nseindia.com/content/historical/EQUITIES/2012/JUN/cm15JUN2012bhav.csv.zip

答案 1 :(得分:6)

使用:

wget -U mozilla http://www.nseindia.com/content/historical/EQUITIES/2012/JUN/cm15JUN2012bhav.csv.zip

有些网站只是阻止wget user-agent下载文件。我刚用这个命令下载了该文件。它有效。

答案 2 :(得分:2)

我使用curl -O <URL>因为wget不支持HTTPS和其他一些协议。

答案 3 :(得分:1)

Web应用程序或Web服务器可能使用的另一种技术是检查“Referrer”内容标头值。除了指定用户代理之外,可能还需要提供引用URL。

例如,

wget --referer http://freestockphotos.com/Scenery1.html http://freestockphotos.com/SKY/TreeSunset.jpg

如果在从“Scenery1.html”页面导航时未创建目标文件,则此主机似乎拒绝对目标文件的请求。

答案 4 :(得分:0)

有些网站只是阻止wget user-agent下载文件 wget -U'Mozilla / 5.0(X11; U; Linux i686; en-US; rv:1.8.1.6)Gecko / 20070802 SeaMonkey / 1.1.4'http://yourURL.com

相关问题