urlread - IP address could not be determined

5 ビュー (過去 30 日間)
Amit Patel
Amit Patel 2025 年 1 月 29 日
コメント済み: Amit Patel 2025 年 1 月 30 日
Hi team
I am using EODHD.COM for stock data. I get the following error every now and then. example - if I am iterating over say 50 stocks data, the code sometimes throw an error for 1 stock, then I rerun the full script allover again and it will work. I used webread to start with but webread doesn't even read the webpage and returns no data (urlread returns data instead).
Error using urlreadwrite_legacy (line 88)
The IP address of "eodhd.com" could not be determined.
Error in urlreadwrite (line 88)
[output,status] = urlreadwrite_legacy(fcn,catchErrors,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in urlread (line 16)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in NSE_all (line 78)
EOD_data = urlread(URL2); % json data
^^^^^^^^^^^^^
My codes are:
url2A = 'https://eodhd.com/api/eod/';
url2B = '?from=';
url2C = '&period=d&api_token=';
url2D = '&fmt=json';
From = datetime("today") - (365 * 20);
dt_str = char(From);
URL2 = url2A + company + url2B + dt_str + url2C + token + url2D;
EOD_data = urlread(URL2);
*please note company is a name of the stock ticker I take from the list for the For loop so I iterate through multiple companies stocks.
Is it possible to tell urlread to wait longer and try more before throwing an error? or even keep trying for the specified time? I want urlread to not stop my script at any random time. I am new to Matlab so if anyone can help it would be great.

採用された回答

Walter Roberson
Walter Roberson 2025 年 1 月 29 日
urlread accepts a Timeout option
However, the Timeout is on reading data only. There is no option for telling urlread to retry unsuccessful connections.
Note: urlread() is not longer recommended. It is recommended that you switch to webread instead.
  1 件のコメント
Amit Patel
Amit Patel 2025 年 1 月 30 日
thanks Walter. I would have appreciated bit more help on why webread() returns no data whereas urlread() returns data. I am not using any other arguments inside the brackets other than the url itself. Also to continue after the https errors I will introduce try catch into my codes too.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWeb Services についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by