Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access the downloaded content with wget for responses with http code different than 200 OK

Tags:

wget

I cannot find a switch in wget which would allow me to see the body of the response if the server returns a status other than 200 OK.

For example

wget 'http://stackoverflow.com/xxx'

will result in

--2012-02-08 16:38:32--  http://stackoverflow.com/xxx
Resolving stackoverflow.com... 64.34.119.12
Connecting to stackoverflow.com|64.34.119.12|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-02-08 16:38:32 ERROR 404: Not Found.

Is it possible access the html document which stackoverflow returns for 404 error?

I know curl would do it, the question is how to do it with wget.

Thanks

Tymek

like image 420
tymtam Avatar asked Nov 21 '25 18:11

tymtam


1 Answers

wget can't do this, but this should work:

curl -R -O http://stackoverflow.com/xxx

Also see https://superuser.com/questions/253826/how-to-use-wget-to-download-http-error-pages

like image 62
PiTheNumber Avatar answered Nov 24 '25 12:11

PiTheNumber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!