简单的天气预报
说明:因新浪的天气页面有些广告,网页加载速度太慢,说以本 工具无多大实际作用 演示图: 源码: #cs ____________________________________
AutoIt 版本: 3.2.11.5第一版) 脚本作者: Zhuzb Email: QQ/TM: zhuzb@qq.com 脚本版本: 脚本功能: 天气预报 #ce _______________脚本开始_________________ #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> If FileExists(@TempDir&"\Weathertemp.txt") Then FileDelete(@TempDir&"\Weathertemp.txt") EndIf FileInstall(@ScriptDir&"\Weathertemp.txt", @TempDir&"\Weathertemp.txt") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("天气预报", 575, 570, 193, 125) $Group1 = GUICtrlCreateGroup("", 8, 8, 551, 49) $Label1 = GUICtrlCreateLabel("城 市:", 48, 24, 76, 24, BitOR($SS_CENTER,$SS_CENTERIMAGE)) $Button1 = GUICtrlCreateButton("搜索", 376, 24, 75, 24, 0) $Input1 = GUICtrlCreateInput("请输入地名", 136, 24, 225, 24) GUICtrlCreateGroup("", -99, -99, 1, 1) ;封闭组框 $oShell = ObjCreate("Shell.Explorer.2") $GUIActiveX= GUICtrlCreateObj($oShell, 8, 70 ,558, 480) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetState() ;Show GUI While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $address=GUICtrlRead($Input1) $Url="http://php.weather.sina.com.cn/search.php?city= "& $address &"" $oIE = _IECreate ($url, 0, 0) $sHTML = _IEBodyReadHTML ($oIE) $sHTML=StringRegExpReplace ($sHTML, "\r\n", "") $sHTML= StringRegExp($sHTML, "<!-- 天气状况 begin.*?天气状况 end -->",1) $file = FileRead(@TempDir&"\Weathertemp.txt") $text = StringReplace($file, "</body>", $sHTML[0]&"</body>") If FileExists(@TempDir&"\Weathertemp.htm") Then FileDelete(@TempDir&"\Weathertemp.htm") EndIf FileWrite(@TempDir&"\Weathertemp.htm", $text) $oShell.navigate(@TempDir&"\Weathertemp.htm") EndSwitch WEnd GUIDelete() |
<< 零网关切换工具本站专用语法高亮转换工具 >>
查看所有评论

