|
<div id="here">内容</div>
网页很大,加载很慢,比如淘宝,网易,腾讯。
只想要其中的一部分内容,能不能判断当网页对象ID为here,已经加载进来完毕后就停止加载,因为想要得到到已经加载进来了,执行$oIE.Stop(),省去后面那些无用的内容载入。
在论坛里找到函数,修改完貌似没什么效果,还是要加载完。
#include <IE.au3>
$oIE = _IECreateEmbedded()
$Form = GUICreate("测试", 600, 600)
GUICtrlCreateObj($oIE, 0, 0, 600, 600)
GUISetState()
_IENavigate($oIE, "http://www.taobao.com/", 0)
$oEle = _IEWaitEle($oIE, "q")
$oEle.value = "你好"
Do
Until GUIGetMsg() = -3
Func _IEWaitEle(ByRef $o_object, $o_id, $complete = false, $timeout = 300000) ;_IEWaitEle(IE对象,元素id或name,是否等待加载完成,超时值)
If Not IsObj($o_object) Then
__IEErrorNotify("Error", "_IEPropertyGet", "$_IEStatus_InvalidDataType")
Return SetError($_IEStatus_InvalidDataType, 1, 0)
EndIf
If Not __IEIsObjType($o_object, "browserdom") Then
__IEErrorNotify("Error", "_IEPropertyGet", "$_IEStatus_InvalidObjectType")
Return SetError($_IEStatus_InvalidObjectType, 1, 0)
EndIf
Local $o_Init = TimerInit()
While TimerDiff($o_Init) < $timeout
$o_doc = _IEDocGetObj($o_object)
If IsObj($o_doc) Then
$o_Ele = _IEGetObjById($o_object, $o_id)
If Not IsObj($o_Ele) Then $o_Ele = _IEGetObjByName($o_object, $o_id)
If IsObj($o_Ele) And ((Not $complete) Or ($o_Ele.readyState == 'loaded' Or $o_Ele.readyState == 'complete')) Then
$o_object.Stop()
Return $o_Ele
EndIf
EndIf
Sleep(100)
WEnd
Return SetError(0, 0, 0)
EndFunc |
|