25 lines
697 B
Plaintext
25 lines
697 B
Plaintext
-- demo\rosetta\web_scrape.exw
|
|
include builtins\libcurl.e
|
|
include builtins\timedate.e
|
|
|
|
object res = curl_easy_perform_ex("https://tycho.usno.navy.mil/cgi-bin/timer.pl")
|
|
if string(res) then
|
|
res = split(res,'\n')
|
|
for i=1 to length(res) do
|
|
integer k = match("UTC",res[i])
|
|
if k then
|
|
res = res[i][5..k-2]
|
|
exit
|
|
end if
|
|
end for
|
|
?res
|
|
if string(res) then
|
|
timedate td = parse_date_string(res, {"Mmm. d, hh:mm:ss"})
|
|
td[DT_YEAR] = date()[DT_YEAR]
|
|
?format_timedate(td,"h:mpm Dddd ddth Mmmm")
|
|
?format_timedate(date(),"h:mpm Dddd ddth Mmmm")
|
|
end if
|
|
else
|
|
?{"some error",res,curl_easy_strerror(res)}
|
|
end if
|