以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  判断webbrowser网页是否加载完整的通用函数,请大咖指导  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=63213)

--  作者:ycli368
--  发布时间:2015/1/16 11:04:00
--  判断webbrowser网页是否加载完整的通用函数,请大咖指导

下面这个使用过程中,还是无法实现,网页完全加载完的准确判断,请高手指导!

Public Function WaitWebPageLoad(webBrowser1 As System.Windows.Forms.WebBrowser)
Dim i As Integer
Dim sUrl As String
While (True)
    YanShi(1000)  \'系统延迟50毫秒,够少了吧!
    If webBrowser1.ReadyState = System.Windows.Forms.WebBrowserReadyState.Complete Then \'先判断是否发生完成事件.
       
        If (Not webBrowser1.IsBusy) Then \'再判断是浏览器是否繁忙
           
            i = i + 1
            If (i = 2) Then
                sUrl = webBrowser1.Url.ToString()
                If (sUrl.Contains("res:")) Then \'这是判断没有网络的情况下
                   
                    Return False
                Else
                   
                    Return True
                End If
            End If
            Continue While
        End If
        i=0
    End If
End While
End Function


--  作者:有点甜
--  发布时间:2015/1/16 11:07:00
--  

1、

 

Dim web As New System.Windows.Forms.WebBrowser()
web.ScriptErrorsSuppressed = True
web.Navigate("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName=59316")
 
Do Until web.ReadyState = 4
    Application.DoEvents
Loop

 

output.show(web.Document.Body.InnerText)

 

2、可以通过循环判断某一个元素是否出现来判断。