regex - Downloading data from website -
I use the following code to download two files from one website to a folder
I want to download some files that include "MOD09GA.A2008077.h22v05.005.2008080122814.hdf" and "MOD09GA.A2008077.h23v05.005.2008080122921 HDF". But I do not know how to select these files. The codes below download all the files, but I need two of them.
Do anyone have any ideas?
URL = 'http://e4ftl01.cr.usgs.gov/MOLT/MOD09GA.005/2008.03.17/'; LocalPath = 'E: / myfolder /' on the local path; Read% HTML content and parse file names with * .hdf urlContents = urlread (URL); Ret = regexp (urlContents, '"\ s + .hdf.xml"', 'match'); Loop on all files and download them to k = 1: length (copy) filename = rate {k} (2: end-1); FilepathOnline = strcat (URL, file name); FilepathLocal = fullfile (Local Path, Filename); Urlwrite (file pathOnline, file path local);
instead regexp with token
Try:
localPath = 'E: / myfolder /'; UrlContents = 'aaaa' MOD09GA.A2008077.h22v05.005.2008080122814.hdf.xml "and" MOD09GA.A2008077.h23v05.005.2008080122921.hdf.xml "aaaaa '; Ret = regexp (urlContents,'" (\ S +) (?: \. \ D +) {2} (\ .hdf \ .xml) "',' token ');% for every file name for K = 1 loop: length (copy) file name = [rate } {:}]; FilepathLocal = fullfile (localpath, filename) end
Comments
Post a Comment