关于天气获取的源码,求高手帮助修改
本帖最后由 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 = [["{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 在线等:face (23): 人迹罕至啊:face (5): :face (17):不是太会这个,帮顶一下。。。 :face (37):继续等待大侠.... 还在等......................... 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", "101120609")
_loaddata()
GUIDelete($form1_1)
GUISetState(@SW_SHOW)
$input = GUICtrlCreateInput("", 30, 500, 160, 20)
GUICtrlSetTip(-1, "输入城市名(推荐)或电话区号后回车")
$button1 = GUICtrlCreateButton("搜索", 200, 500, 70, 20)
Dim $AccelKeys = [["{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 行家一出手,就知有没有。多谢楼上大侠!:face (20): 解决了?留名。。。我也试试 确实不错,只要把101120609改一下,就行了,我把它改为101281901 问题解决了,就是不能编译,出现编译错误,估计是网站有个地方修改了 只可惜,没办法编译好像 问题解决了,就是不能编译,出现编译错误,估计是网站有个地方修改了
a000000 发表于 2009-6-6 14:53 http://www.autoitx.com/images/common/back.gif
是啊
我得去看看能不能改 问题找到了....人家源码里带了东西,我没下载,只复制了源码:
源码跟包见:
http://www.autoitx.com/forum.php?mod=viewthread&tid=6178&highlight=%CC%EC%C6%F8 还不行,差ini
页:
[1]
2