Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wget not working

Tags:

ubuntu

On Ubuntu, I am trying to download a file (from a script) using wget. Buildling a program to download this file everyday and load to a hadoop cluster.

however, the wget fails, with the following message.

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.

when I try the same url in firefox or equivalent, it works just fine. And yes, there is no license agreement kind of thing involved...

Am I missing something basic regarding wget ??

like image 353
Raghav Avatar asked Jun 15 '12 22:06

Raghav


People also ask

Why wget is not working?

If you get the -bash: wget: command not found error on Mac, Linux or Windows, it means that the wget GNU is either not installed or does not work properly. Go back and make sure that you installed wget properly.

How do I fix wget command not found?

Install wget command on Ubuntu After completing the install, again run the previous command to check the install version of this command. Run the wget command with –h option to display all option details of this command.

How do I know if wget is working?

Installing Wget To check whether the Wget package is installed on your system, open up your console, type wget , and press enter. If you have wget installed, the system will print wget: missing URL . Otherwise, it will print wget command not found .


2 Answers

The site blocks wget because wget uses an uncommon user-agent by default. To use a different user-agent in wget, try:

wget -U Mozilla/5.0 http://www.nseindia.com/content/historical/EQUITIES/2012/JUN/cm15JUN2012bhav.csv.zip
like image 116
enderskill Avatar answered Oct 12 '22 20:10

enderskill


Use:

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

Some sites simply prevent wget user-agent to download files. I just downloaded that file with this command. It works.

like image 38
Zagorax Avatar answered Oct 12 '22 21:10

Zagorax