MATLAB: Download file from a url

web downloadwebsave

I am trying to download a file from the following URL
If I enter this request in Chrome, the file will be downloaded automatically.
I have tried to use websave, which gives the following
options.Timeout = Inf;
websave('xxx.csv','https://sdw-wsrest.ecb.europa.eu/service/data/YC/B.U2.EUR.4F.G_N_C.SV_C_YM.?startPeriod=2020-08-31&endPeriod=2020-08-31&format=csvdata',options)
Error using websave (line 94)
The connection to URL 'https://sdw-wsrest.ecb.europa.eu/service/data/YC/B.U2.EUR.4F.G_N_C.SV_C_YM.?startPeriod=2020-08-31&endPeriod=2020-08-31&format=csvdata' timed out
after 2147.4830000000002 seconds. Set options.Timeout to a higher value.
Can anyone help,please?

Best Answer

Hello Xuewei,
Your script seems to have invalid websave arguments.
Please try following script.
websave('xxx.csv','https://sdw-wsrest.ecb.europa.eu/service/data/YC/B.U2.EUR.4F.G_N_C.SV_C_YM.?startPeriod=2020-08-31&endPeriod=2020-08-31&format=csvdata','Timeout',Inf)
or
options.Timeout = Inf;
websave('xxx.csv','https://sdw-wsrest.ecb.europa.eu/service/data/YC/B.U2.EUR.4F.G_N_C.SV_C_YM.?startPeriod=2020-08-31&endPeriod=2020-08-31&format=csvdata','Timeout',options.Timeout)
Regards,
stozaki