以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  web浏览器选择性加载  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=70003)

--  作者:luodang2050
--  发布时间:2015/6/14 15:05:00
--  web浏览器选择性加载
你好,自定义web浏览器加载特定网址,为了提高响应速度,能否加载时过滤掉图片等没用信息?
--  作者:大红袍
--  发布时间:2015/6/14 15:46:00
--  

这样写

 

Dim url As String = "http://www.baidu.com"
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    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()
    Dim reg As new System.Text.RegularExpressions.Regex("src=+.*?((.jpg)|(.png)|(.gif))")
    str = reg.replace(str, "")
    FileSys.WriteAllText("d:\\test.htm", str, False)
catch ex As exception
    msgbox(ex.Message)
End try

Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser1").Basecontrol
web.ScriptErrorsSuppressed = True
web.Navigate("d:\\test.htm")