download file from a url

38 views (last 30 days)
Xuewei Zhu
Xuewei Zhu on 8 Sep 2020
Commented: Xuewei Zhu on 8 Sep 2020
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?
  2 Comments
VBBV
VBBV on 8 Sep 2020
Edited: VBBV on 8 Sep 2020
Try this
% if true
% code
% end
options = weboptions('Timeout', Inf);
filename = 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)
Xuewei Zhu
Xuewei Zhu on 8 Sep 2020
options = weboptions('Timeout', Inf);
filename = 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.
The same error message :(

Sign in to comment.

Accepted Answer

stozaki
stozaki on 8 Sep 2020
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
  3 Comments
stozaki
stozaki on 8 Sep 2020
Works from my system. Perhaps you have a firewall active?
Xuewei Zhu
Xuewei Zhu on 8 Sep 2020
indeed!. After setting up the proxy and port under preference -> matlab -> web. I am able to download the files now :)

Sign in to comment.

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!