关于侦测网页问题
本帖最后由 stcyk 于 2010-10-31 19:47 编辑我au3里面加载了个web网页,web内容是很多行,每行后面都带了个查看按钮,我想把用户点击每个查看按钮后对应该记录在au3里面msbox显示出来,不知道思路应该怎样做,大家帮忙想想
下面是我的代码,当点击一张图片的时候,可以传递图片的路径到au3那#include <IE.au3>
$oIE = _IECreateEmbedded()
$formOption = GUICreate("", 800, 620)
GUISetState(@SW_SHOW)
$web = "http://image.baidu.com/i?ct=201326592&cl=2&lm=-1&tn=baiduimage&pv=&z=0&word=%C3%F7%D0%C7&s=0&oq=%C3%F7&f=3&rsp=0#width=&height=&z=0&fb=0&ic=0&lm=-1&face=0"
$webGUI = GUICtrlCreateObj($oIE, 11, 96, 781, 475)
$oIE.navigate("about:blank")
$oIE.document.body.style.border = "0"
$oIE.document.write("<body style='border:0;margin:0px'><iframe scrolling=no frameborder=0 src =" & $web & " width=100% height=100%></iframe></body>")
$oIE.refresh
$oIE.document.body.scroll = "no"
While 1
$nMsg = GUIGetMsg()
WEnd 没读懂问题 你把网址发过来 或者截个图 例如我内嵌了这个页面,然后点击了任何一张图片,都在au3里面弹出个MsgBox,写出该图片地址就好了,能这样做吗?#include <IE.au3>
$oIE = _IECreateEmbedded()
$formOption = GUICreate("", 800, 620)
GUISetState(@SW_SHOW)
$web = "http://image.baidu.com/i?ct=201326592&cl=2&lm=-1&tn=baiduimage&pv=&z=0&word=%C3%F7%D0%C7&s=0&oq=%C3%F7&f=3&rsp=0#width=&height=&z=0&fb=0&ic=0&lm=-1&face=0"
$webGUI = GUICtrlCreateObj($oIE, 11, 96, 781, 475)
$oIE.navigate("about:blank")
$oIE.document.body.style.border = "0"
$oIE.document.write("<body style='border:0;margin:0px'><iframe scrolling=no frameborder=0 src =" & $web & " width=100% height=100%></iframe></body>")
$oIE.refresh
$oIE.document.body.scroll = "no"
While 1
$nMsg = GUIGetMsg()
WEnd 谢谢 收藏了 学习中 怎么没人帮帮我呢 给你一个例子,应该能解决你的问题。; Example script, showing the usage of COM Event functions.
; Requires at least AutoIt beta version 3.1.1.104 !
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
; We use a very simple GUI to show the results of our Events.
#include "GUIConstantsEx.au3"
$GUIMain=GUICreate ( "Event Test", 600,500 )
$GUIEdit=GUICtrlCreateEdit ( "Test Log:" & @CRLF,10, 20, 580, 400)
$GUIProg=GUICtrlCreateProgress( 10,5, 580,10)
$GUIExit=GUICtrlCreateButton ( " Close ", 250, 450, 80,30)
GUISetState () ;Show GUI
WinSetOnTop($GUIMain, '', 1)
; We prepare the Internet Explorer as our test subject
$oIE=ObjCreate("InternetExplorer.Application.1")
With $oIE
.Visible=1
.Top = (@DesktopHeight-400)/2
.Height=400 ; Make it a bit smaller than our GUI.
.Width=600
.Silent=1 ; Don't show IE's dialog boxes
;~ $IEWnd=HWnd(.hWnd); Remember the Window, in case user decides to close it
EndWith
; We choose for a specific Internet Explorer interface 'DWebBrowserEvents' because the IE is subject
; to modifications by e.g. Visual Studio and Adobe Acrobat Reader. If you have IE-plugins installed,
; AutoIt might not be able to find the correct interface automatically.
$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")
if @error then
Msgbox(0,"AutoIt COM Test", _
"ObjEvent: Can't use event interface 'DWebBrowserEvents'. Error code: " & hex(@error,8))
exit
endif
; Now starting to load an example Web page.
$URL = "http://www.AutoItScript.com/"
$oIE.Navigate( $URL )
sleep(1000) ; Give it some time to load the web page
GUISwitch ( $GUIMain ); Switch back to our GUI in case IE stealed the focus
; Waiting for user to close the GUI.
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE or $msg = $GUIExit Then ExitLoop
Wend
$EventObject.Stop ; Tell IE we don't want to receive events.
$EventObject=0 ; Kill the Event Object
If WinExists($IEWnd) then $oIE.Quit ; Close IE Window
$oIE=0 ; Remove IE from memory (not really necessary).
GUIDelete () ; Remove GUI
exit ; End of our Demo.
; A few Internet Explorer Event Functions
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/webbrowser.asp
Func IEEvent_BeforeNavigate($URL, $Flags, $TargetFrameName, $PostData, $Headers, $Cancel)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ( $GUIEdit, "BeforeNavigate: " & $URL & " Flags: " & $Flags & " tgframe: " & $TargetFrameName & " Postdat: " & $PostData & " Hdrs: " & $Headers & " canc: " & $Cancel& @CRLF, "append" )
EndFunc
Func IEEvent_ProgressChange($Progress, $ProgressMax)
If $ProgressMax > 0 Then
GUICtrlSetData($GUIProg, ($Progress * 100) / $ProgressMax)
EndIf
EndFunc
Func IEEvent_StatusTextChange($Text)
GUICtrlSetData ( $GUIEdit, "IE Status text changed to: " & $Text & @CRLF, "append" )
EndFunc
Func IEEvent_PropertyChange( $szProperty)
GUICtrlSetData ( $GUIEdit, "IE Changed the value of the property: " & $szProperty & @CRLF, "append" )
EndFunc
Func IEEvent_DownloadComplete()
GUICtrlSetData ( $GUIEdit, "IE has finished a navigation operation" & @CRLF, "append" )
EndFunc
Func IEEvent_NavigateComplete($URL)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ( $GUIEdit, "IE has finished loading URL: " & $URL & @CRLF, "append" )
EndFunc
Func IEEvent_($EventName)
; This is an optional event function to catch non-defined events.
; The parameter contains the name of the event being called.
GUICtrlSetData ( $GUIEdit, "Uncatched event: " & $EventName & @CRLF, "append" )
EndFunc 回复 6# 破帽遮颜
怎么运行后什么都没有呢? 有了,但是这个是监测,如果要获得点击的地址应该怎么做呢? 回复 8# stcyk
点击也有消息返回的。 回复 9# 破帽遮颜
请问如何获取到这个链接呢? 呵呵看看了
页:
[1]