本帖最后由 afan 于 2009-10-11 00:19 编辑
或者改正则:#include <IE.au3>
Opt("GUICloseOnESC", 0)
Opt("TrayAutoPause", 0)
Opt("TrayMenuMode", 1)
$g_szVersion = "天气预报"
If WinExists($g_szVersion) Then Exit ; 此脚本已经运行了
AutoItWinSetTitle($g_szVersion)
Local Const $weatherFile = @ScriptDir & "\天气预报.ini"
Local Const $city = IniRead($weatherFile, "天气预报", "城市", "上海")
$Url = "http://php.weather.sina.com.cn/search.php?city=" & $city
$oIE = _IECreate($Url, 0, 0)
$sHTML = _IEBodyReadHTML($oIE)
Local $weather = '', $weatheren = '', $wind = '', $ultraviolet = ''
$array = StringRegExp($sHTML, 'class=w-icon.+\s<H2>(.*)</H2>', 3)
If @error = 0 Then $weather = $array[0]
$array = StringRegExp($sHTML, 'class=w-number>[^>]+>(.*)</SPAN>[^>]+>(.*)</SPAN>', 1)
If @error = 0 Then $weatheren = $array[0] & '~' & $array[1]
$array = StringRegExp($sHTML, '<LI>风力:(.*)\s</LI>', 1)
If @error = 0 Then $wind = $array[0]
$array = StringRegExp($sHTML, '<LI>紫外线.+>(.*)</SPAN>', 1)
If @error = 0 Then $ultraviolet = $array[0]
MsgBox(0, 0, $weather & $weatheren & $wind & $ultraviolet)
IniWrite($weatherFile, "天气预报", "城市", $city)
IniWrite($weatherFile, "天气预报", "天气", $weather)
IniWrite($weatherFile, "天气预报", "温度", $weatheren)
IniWrite($weatherFile, "天气预报", "风力", $wind)
IniWrite($weatherFile, "天气预报", "紫外线", $ultraviolet)
_IEQuit($oIE)
Exit
|