Downloading a compressed archive folder from a URL

5 次查看(过去 30 天)
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

采纳的回答

Cris LaPierre
Cris LaPierre 2023-12-18
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by