Ошибка загрузки error wget download

linux

TS-FROJER

Пытаюсь скачать файл через wget
HTTP request sent, awaiting response… 403 Forbidden
2019-12-21 21:41:12 ERROR 403: Forbidden.


  • Вопрос задан

    более трёх лет назад

  • 3936 просмотров


Комментировать

Пригласить эксперта


Ответы на вопрос 1

Сервер запрещает доступ к файлу. Если это не навороченная защита и для скачивания файла не нужно предварительно авторизовываться, то думаю будет достаточно поменять useragent wget’у

--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0"


Похожие вопросы


  • Показать ещё
    Загружается…

06 июн. 2023, в 00:15

30000 руб./за проект

05 июн. 2023, в 23:42

300 руб./за проект

05 июн. 2023, в 23:25

25000 руб./за проект

Минуточку внимания

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

asked Oct 1, 2011 at 23:47

Sam Kong's user avatar

2

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»

answered Oct 2, 2011 at 0:05

blotus's user avatar

blotusblotus

4064 silver badges3 bronze badges

2

I had the same problem with a Google Docs URL. Enclosing the URL in quotes did the trick for me:

wget "https://docs.google.com/spreadsheets/export?format=tsv&id=1sSi9f6m-zKteoXA4r4Yq-zfdmL4rjlZRt38mejpdhC23" -O sheet.tsv

answered May 5, 2015 at 21:52

e18r's user avatar

e18re18r

7,4124 gold badges44 silver badges40 bronze badges

1

You will also get a 404 error if you are using ipv6 and the server only accepts ipv4.

To use ipv4, make a request adding -4:

wget -4 http://www.php.net/get/php-5.4.13.tar.gz/from/this/mirror

answered Mar 17, 2013 at 19:27

Eli White's user avatar

Eli WhiteEli White

9941 gold badge9 silver badges20 bronze badges

0

I had same problem.
Solved using single quotes like this:

$ wget 'http://www.icerts.com/images/logo.jpg'

wget version in use:

$ wget --version
GNU Wget 1.11.4 Red Hat modified

answered Nov 9, 2017 at 13:57

Mauricio's user avatar

MauricioMauricio

3934 silver badges9 bronze badges

Wget 404 error also always happens if you want to download the pages from WordPress-website by typing

wget -r http://somewebsite.com

If this website is built using WordPress you’ll get such an error:

ERROR 404: Not Found.

There’s no way to mirror WordPress-website because the website content is stored in the database and wget is not able to grab .php files. That’s why you get Wget 404 error.

I know it’s not this question’s case, because Sam only wants to download a single picture, but it can be helpful for others.

answered Jan 6, 2019 at 12:55

Dmytro Lopushanskyy's user avatar

1

Actually I don’t know what is the reason exactly, I have faced this like of problem.
if you have the domain’s IP address (ex 208.113.139.4), please use the IP address instead of domain (in this case www.icerts.com)

wget 192.243.111.11/images/logo.jpg

Go to find the IP from URL https://ipinfo.info/html/ip_checker.php

answered Aug 27, 2020 at 11:23

Mafei's user avatar

MafeiMafei

2,6962 gold badges15 silver badges32 bronze badges

I want to add something to @blotus’s answer,

In case adding the referrer header does not solve the issue, May be you are using the wrong referrer (Sometimes the referrer is different from the URL’s domain name).

Paste the URL on a web browser and find the referrer from developer tools (Network -> Request Headers).

answered Jun 25, 2021 at 11:26

damithdev's user avatar

I met exactly the same problem while setting up GitHub actions with Cygwin. Only after I used wget --debug <url>, I realized that URL is appended with 0xd symbol which is r (carriage return).

For this kind of problem there is the solution described in docs:

you can also use igncr in the SHELLOPTS environment variable

So I added the following lines to my YAML script to make wget work properly, as well as other shell commands in my GHA workflow:

env:
  SHELLOPTS: igncr 

answered Nov 24, 2022 at 12:51

Rom098's user avatar

Rom098Rom098

2,4254 gold badges34 silver badges51 bronze badges

Опубликовано 16.11.2022

При скачивании файлов wget, у него есть одна особенность работы, файл, который нам необходимо скачать, создается перед загрузкой. Другими словами, если сервер, с которого мы скачиваем, вернет ошибку, файл будет испорчен. Данная проблема актуальна в Bash скриптах.

linux

Для решение это проблемы можно использовать механизм использования временных файлов.

Скачиваем файл во временную директорию

wget  "http://example.org/test.dat" -O "/tmp/test.tmp"

Проверяем коды ошибок (если все ОК, должен вернуться 0)

if [ "$?" -eq 0 ]; then
#Действие с файлами
fi

Если необходимо вернуть сообщение об ошибке

if [ "$?" -ne 0 ]; then
rm "/tmp/test.tmpt"
echo "Data download error!"
exit
fi

Для примера работы, ниже приведен пример функции скачивания файла с использованием wget

download(){
local tmp=$(date | md5sum | head -c 20);
local USERAGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0"
wget --user-agent="$USERAGENT" 
$1 
--header="Accept: text/html" 
--keep-session-cookies 
--secure-protocol=TLSv1_3 
--header='Accept-Language: en-us' 
-O /tmp/$tmp


if [ "$?" -eq 0 ]; then
cp /tmp/$tmp "$2"
rm -f /tmp/$tmp
else
rm -f /tmp/$tmp
fi
}

Пример использования

download "http://example.org/test.dat" "/var/test.dat"

Файл /var/test.dat будет обновлен(создан) только в случае успешной загрузки

Sys-Admin Forum

Loading

katiemcquillan

Posts: 2
Joined: Thu Mar 31, 2022 9:51 am America/New_York

Answers: 0

wget 403 forbidden

I am trying to download files I ordered through AppEEARS using wget. I’m getting a 403 forbidden error and I can’t figure out why. I’ve used wget for this exact procedure before and never had any issues. Here is the error message when I try to download a single file:

(base) katiemcquillan@Katies-MacBook-Pro HubbardBrook % wget —load-cookies ~/.urs_cookies —save-cookies ~/.urs_cookies —auth-no-challenge=on —keep-session-cookies —content-disposition —verbose https://appeears.earthdatacloud.nasa.gov (/api/bundle/6d9a8fc2-e993-45c4-8e5e-9b6ccb7d99ad/a8857e3b-1f99-429a-abe8-429d6fabde5e/ECO2LSTE.001_SDS_QC_doy2021001123930_aid0001.tif)
—2022-04-04 15:43:59— https://appeears.earthdatacloud.nasa.gov (/api/bundle/6d9a8fc2-e993-45c4-8e5e-9b6ccb7d99ad/a8857e3b-1f99-429a-abe8-429d6fabde5e/ECO2LSTE.001_SDS_QC_doy2021001123930_aid0001.tif)
Resolving appeears.earthdatacloud.nasa.gov (appeears.earthdatacloud.nasa.gov)… 99.84.111.29, 99.84.111.48, 99.84.111.125, …
Connecting to appeears.earthdatacloud.nasa.gov (appeears.earthdatacloud.nasa.gov)|99.84.111.29|:443… connected.
HTTP request sent, awaiting response… 403 FORBIDDEN
2022-04-04 15:43:59 ERROR 403: FORBIDDEN.

I wasn’t sure if I made the .netrc / cookies files correctly so I tried with my username and password and got basically the same error:
(base) katiemcquillan@Katies-MacBook-Pro HubbardBrook % wget user=katiemcquillan password=fakepassword —auth-no-challenge=on —keep-session-cookies —content-disposition —verbose https://appeears.earthdatacloud.nasa.gov (/api/bundle/6d9a8fc2-e993-45c4-8e5e-9b6ccb7d99ad/a8857e3b-1f99-429a-abe8-429d6fabde5e/ECO2LSTE.001_SDS_QC_doy2021001123930_aid0001.tif)

—2022-04-04 16:03:20— http://user=katiemcquillan/
Resolving user=katiemcquillan (user=katiemcquillan)… failed: nodename nor servname provided, or not known.
wget: unable to resolve host address ‘user=katiemcquillan’
—2022-04-04 16:03:20— http://password=fakepassword/
Resolving password=fakepassword (password=fakepassword)… failed: nodename nor servname provided, or not known.
wget: unable to resolve host address ‘password=fakepassword’
—2022-04-04 16:03:20— https://appeears.earthdatacloud.nasa.gov (/api/bundle/6d9a8fc2-e993-45c4-8e5e-9b6ccb7d99ad/a8857e3b-1f99-429a-abe8-429d6fabde5e/ECO2LSTE.001_SDS_QC_doy2021001123930_aid0001.tif)
Resolving appeears.earthdatacloud.nasa.gov (appeears.earthdatacloud.nasa.gov)… 99.84.111.29, 99.84.111.55, 99.84.111.48, …
Connecting to appeears.earthdatacloud.nasa.gov (appeears.earthdatacloud.nasa.gov)|99.84.111.29|:443… connected.
HTTP request sent, awaiting response… 403 FORBIDDEN
2022-04-04 16:03:20 ERROR 403: FORBIDDEN.

What’s weird is it seems unable to find my username when I’m positive that it’s correct.

Any help troubleshooting this would be greatly appreciated!


Tags:


LP DAAC — lien

User Services
User Services
Posts: 86
Joined: Thu Jun 25, 2020 9:51 am America/New_York

Answers: 0

Been thanked: 2 times

Re: wget 403 forbidden

by LP DAAC — lien » Tue Apr 05, 2022 7:55 am America/New_York

Hi Katie,
Just want to see if you were able to try what I suggested yesterday:
Here are a couple things we see that may be causing causing issues, can you give this a try

1.You will need to submit a token, not a username and password, to download an AppEEARS output file. To get this token you can run the following with wget

> wget -q -O — —method POST —user=USERNAME —password=PASSWORD —auth-no-challenge https://appeears.earthdatacloud.nasa.gov

If successful a token will be provided, along with a token_type and expiration which are not needed. This command seems to be finicky. If there are any problems with the command above, try removing all of the spaces between arguments and re-adding them.

2. With the token you can now use wget to download the files within the text file. See below:

> wget —header «Authorization: Bearer TOKEN» -i HBInstantaneous2019-download-list.txt

Replace TOKEN in the command above with the token from the login request.

Please let me know if it still is being a problem.

Also, if you were and it did not work yesterday, could you try again today. We were experiencing database hardware issues since Friday. We had the new hardware installed last evening and those issues should be behind us.
Thanks,
Brett


katiemcquillan

Posts: 2
Joined: Thu Mar 31, 2022 9:51 am America/New_York

Answers: 0

Re: wget 403 forbidden

by katiemcquillan » Wed Apr 06, 2022 8:39 am America/New_York

This worked, thanks for your help!


jw2495

Posts: 1
Joined: Wed Apr 20, 2022 2:15 pm America/New_York

Answers: 0

Re: wget 403 forbidden

by jw2495 » Fri Jul 08, 2022 4:21 pm America/New_York

Hi Katie and Brett,

I am having exactly the same issue and feel so lucky to find this thread. However, for some reason I still cannot get the token with the command.

I tried «wget -q -O — —method POST —user=USERNAME —password=PASSWORD —auth-no-challenge https://appeears.earthdatacloud.nasa.gov», with my own username/password filled in.
I got an error message:
«wget: unrecognized option ‘—method’
Usage: wget [OPTION]… [URL]…»

If I remove the dash in front of —method, there is no error message but nothing shows. So I still don’t get a token to run the second command (or I just don’t know where to find the token?)
«wget —header «Authorization: Bearer TOKEN» -i xxxx-download-list.txt»

Could someone give me a hint to solve this problem? Your response is highly appreciated!

Thanks in advance,
Jiaming


piscini

Posts: 1
Joined: Mon May 22, 2023 8:58 am America/New_York

Answers: 0

Re: wget 403 forbidden

by piscini » Mon May 22, 2023 9:02 am America/New_York

Hello,
I experienced the same error. I have txt list file but wget fails when try do download ECOSTRESS data.

I tried the following solution:
wget -q -O — —method POST —user=USERNAME —password=PASSWORD —auth-no-challenge https://appeears.earthdatacloud.nasa.gov

using my credentials in place of USERNAME and PASSWORD, but no TOKEN is generated
Do You have any idea why?
thanks,
Alessandro


Понравилась статья? Поделить с друзьями:
  • Ошибка загрузки 4002 темы xiaomi
  • Ошибка загрузки windows 10 critical process died
  • Ошибка загрузки 4001 что это
  • Ошибка загрузки windows 10 0xc0000225
  • Ошибка загрузки windows 10 0xc000014c