Programmatic download of weather images
Download daily meteo chart.
This code fetches the day's chart from the Met Office in the UK
'Download html and image from given URL to file on disk.
'LB NL 141?? & Alyce's Restaurant
nomainwin
result = DownloadToFile( "http://www.metoffice.gov.uk/weather/charts/FSXX00T_00.jpg", "SynChart"; date$( "days"); ".jpg")
timer 2000, [on]
wait
[on]
timer 0
if result <> 0 then
print "Error downloading image."
else
'run "mspaint.exe " + chr$(34) + "SynChart"; date$( "days"); ".jpg" + chr$(34)
print : print : print "Done"
end if
end
Function DownloadToFile( urlfile$, localfile$)
open "URLmon" for dll as #url
calldll #url, "URLDownloadToFileA",_
0 as long,_ 'null
urlfile$ as ptr,_ 'url to download
localfile$ as ptr,_ 'save file name
0 as long,_ 'reserved, must be 0
0 as long,_ 'callback address, can be 0
DownloadToFile as ulong '0=success
close #url
end function
Sea surface temperatures
Downloaded from SSEC in the US.
'Download html and image from given URL to file on disk.
'nomainwin
print "SstChart"; date$( "days"); ".gif"
result = DownloadToFile( "http://www.ssec.wisc.edu/data/sst/latest_sst.gif", "SstChart"; str$( date$( "days")); ".gif")
timer 2000, [on]
wait
[on]
timer 0
if result <> 0 then
print "Error downloading image."
else
'print "mspaint.exe SstChart"; str$( date$("days")); ".gif"
run "mspaint.exe SstChart"; str$( date$("days")); ".gif"
print : print : print "Done"
end if
end
Function DownloadToFile( urlfile$, localfile$)
open "URLmon" for dll as #url
calldll #url, "URLDownloadToFileA",_
0 as long,_ 'null
urlfile$ as ptr,_ 'url to download
localfile$ as ptr,_ 'save file name
0 as long,_ 'reserved, must be 0
0 as long,_ 'callback address, can be 0
DownloadToFile as ulong '0=success
close #url
end function