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

Jan
Jan 2022년 3월 12일
편집: Jan 2022년 3월 12일
Please post the images directly instead of an imgur link.
I do not understand this sentence: "that has correct files (xml) files but redundant xml.html files".
alpedhuez
alpedhuez 2022년 3월 12일
These xml files are in the website. But those xml.html files are not in the website. I use delte command in Matlab to remove these files from the download directory. But still would like to know why such things happened.
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
Jan 2022년 3월 12일

0 개 추천

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

alpedhuez
alpedhuez 2022년 3월 12일
Thank you. So should it always end with "\"?
Jan
Jan 2022년 3월 12일
After the drive letter a file separator is required as well as between all folders.
alpedhuez
alpedhuez 2022년 3월 12일
Okay thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

질문:

2022년 3월 12일

댓글:

2022년 3월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by