找回密码
 加入
搜索
查看: 1754|回复: 1

_IECreate的参数问题

[复制链接]
发表于 2009-2-26 15:11:39 | 显示全部楼层 |阅读模式
[au3]#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#cs
函数名:_GoogleWeatherSearchCN
功能:利用google.cn搜索中国城市的天气预报
入口参数:城市名称中文或者拼音,如:"合肥"或者"hefei",例子_GoogleWeatherSearchCN("合肥")
出口参数:包含天气信息的html代码。失败返回""

作者:zerozha@qq.com
QQ:451450451
版本:0.1
#ce
Func _GoogleWeatherSearchCN($s_q)
$Url = 'http://www.google.cn/search?q=tq%20' & $s_q
$oIE = _IECreate($Url, 0, 0, 1, 0)
If @error Then
  $sHTML = _IEBodyReadHTML($oIE)
  $sHTML = StringRegExpReplace($sHTML, "\r\n", "")
  $TmpHTML = StringRegExp($sHTML, "</A></DIV></TD></TR>(.*?)</TBODY></TABLE></DIV><SCRIPT>", 1)
  If @error Then
   $city = StringRegExp($sHTML, "<FONT color=#cc0033>(.*?)</FONT>", 1)
   $tmptext = StringReplace($TmpHTML[0], "/images", "http://www.google.cn/images")
   $text = $city[0] & "<table>" & $tmptext & "</table>"
  Else
   MsgBox(8208, "输入错误", "请输入城市中文名称或拼音")
   $text = ""
  EndIf
Else
  $text = ""
EndIf
Return $text
EndFunc   ;==>_GoogleWeatherSearchCN
[/au3]

这是我写的一个利用google搜索查询天气的函数,有个小问题,没有解决。
[au3] $oIE = _IECreate($Url, 0, 0, 1, 0)[/au3]
这句参数明明是隐藏ie,为什么不行呢?老是弹出ie查询的窗口。
 楼主| 发表于 2009-2-26 15:15:57 | 显示全部楼层
这是一个例子,界面直接用了论坛里一位哥们的代码。
[au3]
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\Documents and Settings\Administrator\桌面\googleweather.ico
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

#include <_GoogleWeatherSearch.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Google天气查询", 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
                        $s_q = GUICtrlRead($Input1)
                        $text = _GoogleWeatherSearchCN($s_q)
                        If $text = "" Then
                                MsgBox(8208, "输入错误", "请输入城市中文名称或拼音,并确认网络链接正常")
                        EndIf
                        If FileExists(@TempDir & "\Weathertemp.htm") Then
                                FileDelete(@TempDir & "\Weathertemp.htm")
                        EndIf
                        FileWrite(@TempDir & "\Weathertemp.htm", $text)
                        $oShell.navigate(@TempDir & "\Weathertemp.htm")
        EndSwitch
WEnd
GUIDelete()
[/au3]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 10:17 , Processed in 0.077374 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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