找回密码
 加入
搜索
查看: 4054|回复: 10

[网络通信] 关于侦测网页问题

  [复制链接]
发表于 2010-10-31 18:41:38 | 显示全部楼层 |阅读模式
本帖最后由 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
发表于 2010-10-31 19:35:16 | 显示全部楼层
没读懂问题   你把网址发过来   或者截个图
 楼主| 发表于 2010-10-31 19:46:26 | 显示全部楼层
例如我内嵌了这个页面,然后点击了任何一张图片,都在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
发表于 2010-10-31 21:54:30 | 显示全部楼层
谢谢 收藏了 学习中
 楼主| 发表于 2010-11-1 00:04:17 | 显示全部楼层
怎么没人帮帮我呢
发表于 2010-11-1 02:20:35 | 显示全部楼层
给你一个例子,应该能解决你的问题。
; 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
 楼主| 发表于 2010-11-1 08:52:24 | 显示全部楼层
回复 6# 破帽遮颜
怎么运行后什么都没有呢?
 楼主| 发表于 2010-11-1 08:54:08 | 显示全部楼层
有了,但是这个是监测,如果要获得点击的地址应该怎么做呢?
发表于 2010-11-1 10:18:24 | 显示全部楼层
回复 8# stcyk

点击也有消息返回的。
 楼主| 发表于 2010-11-1 13:04:22 | 显示全部楼层
回复 9# 破帽遮颜


    请问如何获取到这个链接呢?
发表于 2010-11-3 20:23:30 | 显示全部楼层
呵呵看看了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-16 04:26 , Processed in 0.078280 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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