wget can't download - 404 error

Sam Kong picture Sam Kong · Oct 2, 2011 · Viewed 98.1k times · Source

I tried to download an image using wget but got an error like the following.

--2011-10-01 16:45:42--  http://www.icerts.com/images/logo.jpg
Resolving www.icerts.com... 97.74.86.3
Connecting to www.icerts.com|97.74.86.3|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2011-10-01 16:45:43 ERROR 404: Not Found.

My browser has no problem loading the image. What's the problem? curl can't download either.

Thanks.

Sam

Answer

blotus picture blotus · Oct 2, 2011

You need to add the referer field in the headers of the HTTP request. With wget, you just need the --header arg :

wget http://www.icerts.com/images/logo.jpg --header "Referer: www.icerts.com"

And the result :

--2011-10-02 02:00:18--  http://www.icerts.com/images/logo.jpg
Résolution de www.icerts.com (www.icerts.com)... 97.74.86.3
Connexion vers www.icerts.com (www.icerts.com)|97.74.86.3|:80...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: 6102 (6,0K) [image/jpeg]
Sauvegarde en : «logo.jpg»