Ah, I’m afraid that it’s a specialized answer for Lazarus/Free Pascal/Indy.
99% of the time, a wget to fetch the page, then a grep to search for the key string would do the job. In this case, they added a cookie trap that usually requires a browser with javascript enabled to pass the test.
There’s probably a way to gimmick wget to do it, but I already had an app to fetch the weather forecast, so adding a TIdCookieManager, and disarming their cookie trap wasn’t a big deal. Their cookie trap page lacks a title, so that’s how I know that I have to set the cookie and try again.
procedure TPiCrateForm.CheckForCovid;
var
s : string;
sPage : string;
sCode : string;
sIP : string;
slX : TStringList;
begin
slX := TStringList.Create;
s := FormatDateTime('nn:ss', now);
if (s = '06:00') or
(s = '21:00') or
(s = '36:00') or
(s = '52:00') then
begin
sPage := '';
Memo2.Lines.Clear;
if FetchPage(CovidURL, sPage) then
begin
if pos('<title>', sPage) = 0 then
begin
// Cookie warp fuckery
slX.Text := sPage;
s := ''''+between(sPage, 'setCookie(''', ');', false);
sCode := Between(s, '''', ''',', false);
sIP := Between(s, ', ''', '''', false);
IdCookieManager1.AddServerCookie(sCode +'='+sIP, TIdURI.Create('https://www.york.ca'));
FetchPage(CovidURL, sPage);
end;
slX.Text := sPage;
//slX.SaveToFile('test.txt');
if pos('Vaccinations appointments fully booked.', sPage) = 0 then
begin
// Message is gone, play a sound
PlaySound(COVID_ALERT);
Memo2.Lines.Add(FormatDateTime('hh:nn:ss', now)+' Ready!');
end
else begin
// Temp sound
//PlaySound(COVID_NOP);
Memo2.Lines.Add(FormatDateTime('hh:nn:ss', now)+' Vaccinations appointments fully booked.');
end;
end
else begin
PlaySound(COVID_FAIL);
Memo2.Lines.Add(FormatDateTime('hh:nn:ss', now)+' Fail');
end;
end;
end;