urlread - IP address could not be determined

5 vues (au cours des 30 derniers jours)
Amit Patel
Amit Patel le 29 Jan 2025
Commenté : Amit Patel le 30 Jan 2025
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Jan 2025
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 commentaire
Amit Patel
Amit Patel le 30 Jan 2025
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by