检查Internet Explorer中是否加载了必需文本

时间:2016-05-04 11:55:57

标签: internet-explorer vbscript internet-explorer-8

我正在访问非常复杂的网站,因此Msxml2.XMLHTTP不起作用。我尝试过followint Ie Automation。

'Working
with createobject("internetexplorer.application")
  .navigate url
  Do While .ReadyState = 4: WScript.Sleep 1000: Loop
  Do While .ReadyState <> 4: WScript.Sleep 1000: Loop
  .document.body.createtextrange.select
  .document.execCommand "copy"
  strURL = .document.parentwindow.clipboardData.GetData("text")         
  .quit
end with
MsgBox strURL

但每次都会在Failproof Wait for IE to load

中加载未回复的全部内容

如果我想在instr(strURL, "some text") is true之前加载网页,有什么办法吗?

我不明白为什么.ReadyState = 4没有加载页面。是因为javascript可能还没准备好?

我又加了一个这样的睡眠。

If Not instr(strtxt, "some Text") > 0 then
        WScript.Sleep 10000
    .document.body.createtextrange.select
    .document.execCommand "copy"
  strtxt = .document.parentwindow.clipboardData.GetData("text")

这在我的环境中大部分时间都会产生结果,但我不知道如何检查,直到加载了所需的文本。

1 个答案:

答案 0 :(得分:0)

这是一个想法。

keepSleeping = false 'is my requirement
keepSleeping=instr(.document.body.innerhtml, "sometext") <> 0
while keepSleeping
   WScript.Sleep 20
   keepSleeping=instr(.document.body.innerhtml, "sometext")
wend
相关问题