Downloading a compressed archive folder from a URL
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dinuka Kankanige
il 18 Dic 2023
Commentato: Dinuka Kankanige
il 18 Dic 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
0 Commenti
Risposta accettata
Cris LaPierre
il 18 Dic 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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Downloads in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!