以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]webbrowser控件读取超长网页的问题。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=68421)

--  作者:夜雨寒风
--  发布时间:2015/5/17 17:40:00
--  [求助]webbrowser控件读取超长网页的问题。
Dim web As New System.Windows.Forms.WebBrowser()
Dim webAddr As String = "http://........"

web.ScriptErrorsSuppressed = True
web.Navigate(webAddr)
Do Until web.ReadyState = 4
   Application.DoEvents
Loop

因网页超长,网速快时能完整读取,网速慢时就常出错,据说是设置TimeOut参数,应该如何设置?求教,谢谢!

--  作者:大红袍
--  发布时间:2015/5/17 17:43:00
--  
  出什么错?报什么错?
--  作者:夜雨寒风
--  发布时间:2015/5/17 17:50:00
--  
网页超时
--  作者:大红袍
--  发布时间:2015/5/17 17:57:00
--  

不能用webbroser,你先把内容获取,如果还需要用到webbrowser的话,再给它设置进去吧。

 

Dim url As String = "http://foxtable.com"
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    rqst.TimeOut = 1000 \'一秒
    Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
    Dim stm As System.IO.Stream = rsps.GetResponseStream()
    Dim reader As New System.IO.StreamReader(stm)
    Dim str As String = reader.ReadToEnd
    stm.Dispose()
    Output.Show(str)
catch ex As exception
    msgbox(ex.Message)
End try


--  作者:夜雨寒风
--  发布时间:2015/5/17 20:03:00
--  
谢谢