|
本帖最后由 a000000 于 2009-6-6 14:50 编辑
找到一个很好的源码,可惜打开后是上海的,求高手修改一下让它打开后直接显示这个页面http://www.weather.com.cn/html/weather/101120609.shtml
源码:
#NoTrayIcon
Dim $adds = "http://www.weather.com.cn/html/weather/"
Dim $adde = ".shtml"
Dim $templist = @TempDir & "\my_weather_templist.txt"
Dim $inifile = @ScriptDir & "\weatherconfig.ini"
Dim $splashfile1 = @TempDir & "\my_weather_10.gif"
Dim $splashfile2 = @TempDir & "\my_weather_3.html"
Dim $Combo_text = "清除记录"
Dim $Combotext = $Combo_text
Dim $n = 0
Dim $s = 0
Dim $a = "<SCRIPT language=jscript event=oncontextmenu for=document defer type=text/javascript>return false;</SCRIPT>"
Dim $b = "<SCRIPT language=jscript event=onclick for=document defer type=text/javascript>return false;</SCRIPT>"
FileInstall("my_weather_10.gif", $splashfile1, 1)
FileInstall("my_weather_3.html", $splashfile2, 1)
FileInstall("weatherconfig.ini", $inifile)
$form1_1 = GUICreate("", 504, 60, -1, -1, 0x80000000, BitOR(0x00000080, 0x00000008))
$oIE_1 = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE_1, -12, -17, 534, 95)
$oIE_1.navigate("file:///" & $splashfile2)
GUISetState()
;------------------------------------------------------------
$form1 = GUICreate("天气讯息", 675, 530, -1, -1)
$oIE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($oIE, 2, 2, 672, 485)
$link = IniRead($inifile, "startpage", "start", "101020100")
_loaddata()
GUIDelete($form1_1)
GUISetState(@SW_SHOW)
$input = GUICtrlCreateInput("", 30, 500, 160, 20)
GUICtrlSetTip(-1, "输入城市名(推荐)或电话区号后回车")
$button1 = GUICtrlCreateButton("搜索", 200, 500, 70, 20)
Dim $AccelKeys[1][2] = [["{Enter}", $button1]]
GUISetAccelerators($AccelKeys)
$Combo1 = GUICtrlCreateCombo("浏览记录", 290, 500, 150, 20, 0x0003)
GUICtrlSetData(-1, $Combotext)
$button2 = GUICtrlCreateButton("设为主页", 575, 500, 70, 20)
$button3 = GUICtrlCreateButton("主页", 470, 500, 70, 20)
While 1
$msg = GUIGetMsg()
Switch $msg
Case - 3
_deletehis()
FileDelete($splashfile1)
FileDelete($splashfile2)
Exit
Case $button1
$city = GUICtrlRead($input)
If Int($city) <> 0 Then $city = Int($city)
$link = IniRead($inifile, "index", $city, "")
If $link = "" Then
MsgBox(0, "提示", "对不起,没有你要找的城市")
Else
_loaddata()
$Combotext = $city & "|" & $Combotext
GUICtrlSetData($Combo1, "")
GUICtrlSetData($Combo1, $Combotext, $city)
EndIf
Case $button2
IniWrite($inifile, "startpage", "start", $link)
Case $button3
$link = IniRead($inifile, "startpage", "start", "101020100")
_loaddata()
Case $Combo1
$c_data = GUICtrlRead($Combo1)
Switch $c_data
Case "浏览记录"
Case "清除记录"
_deletehis()
GUICtrlSetData($Combo1, "")
$Combotext = $Combo_text
GUICtrlSetData($Combo1, $Combotext)
Case Else
$city = GUICtrlRead($Combo1)
If Int($city) <> 0 Then $city = Int($city)
$link = IniRead($inifile, "index", $city, "")
_loaddata()
EndSwitch
EndSwitch
WEnd
Func my()
EndFunc ;==>my
Func _deletehis()
Local $i = 0
While 1
$i += 1
$d_list = FileReadLine($templist, $i)
If Not @error Then
FileDelete($d_list)
Else
FileDelete($templist)
ExitLoop
EndIf
WEnd
EndFunc ;==>_deletehis
Func _loaddata()
GUISetState(@SW_LOCK, $form1)
Local $tempfile = @TempDir & "\my_weather_" & $link & ".txt"
If FileExists($tempfile) Then
$html = FileRead($tempfile)
$oIE.document.body.innerHTML = $html
Else
$oIE.navigate($adds & $link & $adde)
Sleep(1000)
While 4 - $oIE.ReadyState()
Sleep(100)
WEnd
$html = $oIE.document.body.innerHTML
$index1 = StringInStr($html, '<DIV class=left_contenttopl>')
$index2 = StringInStr($html, '<DIV class="box_contentl scene_weather"><IFRAME')
$html = StringMid($html, $index1, $index2 - $index1)
$html = $html & @CR & $a & @CR & $b
$oIE.document.body.innerHTML = $html
FileDelete($tempfile)
FileWrite($tempfile, $html)
FileWriteLine($templist, $tempfile)
EndIf
GUISetState(@SW_UNLOCK, $form1)
EndFunc ;==>_loaddata |
|