找回密码
 加入
搜索
查看: 3372|回复: 20

关于天气获取的源码,求高手帮助修改

[复制链接]
发表于 2009-6-6 12:54:29 | 显示全部楼层 |阅读模式
本帖最后由 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
 楼主| 发表于 2009-6-6 13:15:44 | 显示全部楼层
在线等[img]
[/img]
 楼主| 发表于 2009-6-6 13:27:58 | 显示全部楼层
人迹罕至啊
发表于 2009-6-6 13:32:43 | 显示全部楼层
不是太会这个,帮顶一下。。。
 楼主| 发表于 2009-6-6 13:45:37 | 显示全部楼层
继续等待大侠....
 楼主| 发表于 2009-6-6 13:59:45 | 显示全部楼层
还在等.........................
发表于 2009-6-6 14:40:50 | 显示全部楼层
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[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
 楼主| 发表于 2009-6-6 14:50:03 | 显示全部楼层
行家一出手,就知有没有。多谢楼上大侠!
发表于 2009-6-6 14:50:35 | 显示全部楼层
解决了?留名。。。我也试试
发表于 2009-6-6 14:53:18 | 显示全部楼层
确实不错,只要把101120609改一下,就行了,我把它改为101281901
 楼主| 发表于 2009-6-6 14:53:31 | 显示全部楼层
问题解决了,就是不能编译,出现编译错误,估计是网站有个地方修改了
发表于 2009-6-6 14:54:44 | 显示全部楼层
只可惜,没办法编译好像
发表于 2009-6-6 14:55:11 | 显示全部楼层
问题解决了,就是不能编译,出现编译错误,估计是网站有个地方修改了
a000000 发表于 2009-6-6 14:53

是啊


我得去看看能不能改
 楼主| 发表于 2009-6-6 15:04:22 | 显示全部楼层
问题找到了....人家源码里带了东西,我没下载,只复制了源码:
源码跟包见:
http://www.autoitx.com/forum.php ... hlight=%CC%EC%C6%F8
发表于 2009-6-6 15:17:59 | 显示全部楼层
还不行,差ini
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-1 21:25 , Processed in 0.086707 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表