I can further confirm that neither A_LastError or ErrorLevel return anything unusual. Perhaps it's my RegExMatch syntax? As far as I can tell it's fine, but what do I know, eh?
EDIT: Current script is:
Code: Select all
UrlDownloadToFile, https://www.timeanddate.com/worldclock/usa/los-angeles, %A_WorkingDir%\date.txt
if (ErrorLevel=1)
{
MsgBox, Error in retrieving time!
ExitApp
}
Sleep, 5000
FileReadLine, date, %A_WorkingDir%\date.txt, 84
if (ErrorLevel=1)
{
MsgBox, error in FileReadLine
ExitApp
}
RegExMatch(date, "<span id=""ctdat"">(.*)</span>", foundDate)
MsgBox, %foundDate%
ExitApp
As you can see I also explicitly defined A_WorkingDir as the directory so I could both easily see if the file was being downloaded properly and to make sure there were no errors there. I also ensured there was ample time to download the roughly 35kb file before reading anything and also tried changing the extension to .txt instead of .html.
EDIT2: Tried changing the line read to 15 since that's how it shows up in raw notepad and not notepadd++, but still nothing returned. I'm stumped.
EDIT3: I can confirm that I'm using the latest release of AHK so that shouldn't be an issue, not that I think encoding was the actual issue. Just doing my due diligence.
EDIT4: MsgBox, %date% does indeed return the correct line so I'm thinking it must be my RegExMatch syntax or something to do with RegExMatch.
EDIT5: RegExMatch does not throw an error when using the following script:
Code: Select all
FileDelete, %A_WorkingDir%\date.txt
UrlDownloadToFile, https://www.timeanddate.com/worldclock/usa/los-angeles, %A_WorkingDir%\date.txt
if (ErrorLevel=1)
{
MsgBox, Error in retrieving time!
ExitApp
}
Sleep, 5000
FileReadLine, date, %A_WorkingDir%\date.txt, 84
if (ErrorLevel=1)
{
MsgBox, error in FileReadLine
FileDelete, %A_WorkingDir%\date.txt
ExitApp
}
RegExMatch(date, "<span id=""ctdat"">(.*)</span>", foundDate)
if (ErrorLevel!=0)
{
MsgBox, %ErrorLevel%
FileDelete, %A_WorkingDir%\date.txt
ExitApp
}
FileDelete, %A_WorkingDir%\date.txt
MsgBox, %date%
ExitApp