http://tomorrowsgaspricetoday.com
http://www.torontogasprices.com
第一個網站通常每天下午四點半後會公布預估的明天的油價。第二個網站是由網友們發布的各油站實時油價。大多加油站現在都follow第一個網站的預估價,所以各油站差價不大,不值得為便宜幾毛錢跑到很遠的油站去加油。問題是有時一忙就忘了回家前check油價,所以我就用Task Scheduler定時運行一個程序返回明日油價。這個AutoIT script程序如下:
#include
$oIE = _IECreate("http://tomorrowsgaspricetoday.com/toronto-gas-prices.html?city=133",0,0,1,1)
$sHtml = _IEBodyReadHTML($oIE)
$money =StringRegExp($sHtml, "class=predication_gasoline_litre_pro_01>([\d\.]*)", 3)
$trend =StringRegExp($sHtml, "images/gas_arrow_(\w+).gif", 1)
_IEQuit($oIE)
$text="Hi, the gas price is going " & $trend[0] & " " & $money[1] & "cents to " & $money[0] & " cents"
msgbox(0, "Tomorrow Gas Price", $text)
如果想來點有趣的,可以讓程序說話,隻需在msgbox之前加兩句:
$o_speech = ObjCreate ("SAPI.SpVoice")
$o_speech.Speak ('<rate speed="-2"><pitch middle="-10">' & $text & '</pitch></rate>', 8)
編譯好的可執行程序上載到fileserve,好像本板塊不允許鏈接,所以請參見dencode.blogspot.com