Filter löschen
Filter löschen

download file from a url

22 Ansichten (letzte 30 Tage)
Xuewei Zhu
Xuewei Zhu am 8 Sep. 2020
Kommentiert: Xuewei Zhu am 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 Kommentare
VBBV
VBBV am 8 Sep. 2020
Bearbeitet: VBBV am 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 am 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 :(

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by