检查是否在 Internet Explorer 中加载了所需的文本

Check if Required Text is loaded in internet explorer

我正在访问非常复杂的网站,因此 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")

这在我的环境中大部分时间都会给出结果,但在加载所需文本之前我不知道如何检查。

这是一个想法。

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