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
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!