Downloading a compressed archive folder from a URL

5 Ansichten (letzte 30 Tage)
Dinuka Kankanige
Dinuka Kankanige am 18 Dez. 2023
Kommentiert: Dinuka Kankanige am 18 Dez. 2023
I'm trying to download a compressed archive folder such that the download is initiated when I click the link.
The folder name appears to be 'grace_1B_2002-04-08_02.tar' once downloaded.
The code I generated downloads an html file (code is attached herewith). Could anyone please help me fix the code. (R2023a)
% Set the URL for the folder download link
folderURL = 'https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/GRACE_L1B_GRAV_JPL_RL02/2002/grace_1B_2002-04-04_02.tar.gz';
% Set the destination folder where you want to save the downloaded folder
destinationFolder = 'path_to_your_destination_folder';
% Set the filename for the downloaded folder
filename = 'grace_1B_2002-04-04_02.tar';
% Construct the full path for the destination file
fullDestinationPath = fullfile(destinationFolder, filename);
% Download the folder
try
websave(fullDestinationPath, folderURL);
fprintf('Downloaded %s\n', filename);
catch
fprintf('Error downloading %s\n', filename);
end
Thanks in advance

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 18 Dez. 2023
It is a secure site only accessible to signed-in users. I found I could successfully download the file if my request also included my username and password, which were set using weboptions.
url = 'https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/GRACE_L1B_GRAV_JPL_RL02/2002/grace_1B_2002-04-04_02.tar.gz';
opts = weboptions('Username','myUserName','Password','myPassword');
websave('grace_1B_2002-04-04_02.tar.gz',url,opts)

Weitere Antworten (0)

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by