download file from a url

39 次查看(过去 30 天)
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 个评论
VBBV
VBBV 2020-9-8
编辑:VBBV 2020-9-8
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 2020-9-8
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 :(

请先登录,再进行评论。

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by