Page 1 of 1

OpenUrl question

Posted: Friday 25 October 2024 7:40
by ressof
Hi

I writing a script to check electical prices from Nord Pool that uses this URL:

Code: Select all

https://dataportal-api.nordpoolgroup.com/api/DayAheadPrices?date=2024-10-19&market=DayAhead&deliveryArea=SE3&currency=SEK
You can use tomorrow date in the url but the url is only valid sometime after 13:00. Is there a way to check if the URL is valid before I'm trying to open it? If I try to open url from 13:00 and its not valid I get an error message in the log that I don't want.

Re: OpenUrl question

Posted: Friday 25 October 2024 19:42
by habahabahaba
You can try smth like this (curl is needed):

Code: Select all

 	local handler1 = io.popen('curl -s -o /dev/null -w "%{http_code}" "URL_to_check" ')
        local response1 = handler1:read('*a')
            
            
            if (response1 == "200") then  -- if OK
            
            
            end

Re: OpenUrl question

Posted: Tuesday 29 October 2024 7:43
by ressof
Thank you for your help