why does websave creates empty files?
3 次查看(过去 30 天)
显示 更早的评论
I run
baseurl = "https://www.sonecompany.com/xml/";
datelimits = datetime({'20080401', '20080601'}, 'InputFormat', 'yyyyMMdd','Format','yyyyMMdd');
subfile_limit = 5; %no more than _5 -- adjust as appropriate
subfile_modifier = ["_" + (1:subfile_limit)] + ".xml";
for Day = datelimits(1):datelimits(2)
daystr = string(Day);
for Sub = subfile_modifier
filename = "A_" + daystr + Sub;
url = baseurl + filename;
% Set up a directory+filename
path_to_save = "E:";
out_name_path = path_to_save+filename;
try
outfilename = websave(out_name_path,url);
fprintf('fetched %s\n', filename);
catch
break; %skip remaining subfiles for this date upon first failure
end
end
end
The output is
that has correct files (xml) files but redundant xml.html files. Why?
3 个评论
Peter Perkins
2022-3-14
Mostly unrelated: You don;'t need both format arguments, just Format will do:
>> datelimits = datetime({'20080401', '20080601'}, 'Format', 'yyyyMMdd')
datelimits =
1×2 datetime array
20080401 20080601
采纳的回答
Jan
2022-3-12
path_to_save = "E:";
out_name_path = path_to_save+filename;
This produces file names like "E:A_20080401_5.xml". A valid file name has a file separator after the drive letter: "E:\" . Prefer fullfile() to join folder and file names.
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String Parsing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!