How to have the MATLAB Web Browser automatically save a downloaded file to a specified directory without prompting
13 次查看(过去 30 天)
显示 更早的评论
Basically I have a script that downloads a series of files from an intranet repository. For each file that the browser attempts to download, a prompt appears which asks which directory to save the file to. Is it possible to have MATLAB skip that prompt and download the file automatically? Additionally, is it possible to specify what path the downloaded file should be saved to?
I used to be able to achieve this by having MATLAB use Chrome to download the file, but Chrome is no longer supported by the respository I'm downloading from. I can have it use Internet Explorer and specify a download folder in the IE options, but I still have to manually click "open" or "save" for each downloaded file. Either way, if I use an external browser, I have to log into the repository from both the MATLAB browser and the external browser, and I'm not able to have MATLAB detect whether a login is necessary for the external browser, which is helpful for having my script run smoothly.
0 个评论
回答(2 个)
Mohammad Sami
2020-8-23
If you have direct links to the file, you can use websave function to save them to the specified location.
if true
url = 'http://heritage.stsci.edu/2007/14/images/p0714aa.jpg';
filename = 'jupiter_aurora.jpg'; % path to save the downloaded file
outfilename = websave(filename,url);
end
0 个评论
Kiran Felix Robert
2020-8-24
Hi Philip,
To download and save the files the websave function can be used. You can specify the path using the filename argument or you can save to the default location and move these later.
Assuming you have the specific URL to all the files (assuming all are csv files), and you want to set the output file name using an iterator, the following example can be used,
for i = 1:N % N is the number of files to retrieve
path_to_save = "C:/WebFiles/";
out_name_path = path_to_save+num2str(i)+".csv"; % This way can be used if iteration is needed
outfilename = websave(out_name_path,URL(i));
end
Kiran Felix Robert
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!