以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教如何获取网页内容  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=71179)

--  作者:supwork
--  发布时间:2015/7/6 18:39:00
--  请教如何获取网页内容

http://222.241.172.223:8008/test

 

这个网页下面就两个字母 FT

如何用代码获取 该网页内容为FT

从而进行决断网络是否能通


--  作者:大红袍
--  发布时间:2015/7/6 19:35:00
--  

Dim url As String = "http://222.241.172.223:8008/test"  \'请按实际升级的路径填写

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
    msgbox(str)
    rsps.Close
catch ex As Exception
    msgbox(ex.message)
End try


 

[此贴子已经被作者于2015/7/6 19:35:01编辑过]

--  作者:supwork
--  发布时间:2015/7/6 20:28:00
--  

谢谢回复

但此回复没有解决问题

http://222.241.172.223:8008/test

打开这个页面,你就只能看到FT两个字母

 

我需要的是从这个页面获取FT这两个字母,即是否能读取到FT两字母

 

回复的代码返回的值 太多了


--  作者:大红袍
--  发布时间:2015/7/6 20:55:00
--  

Dim url As String = "http://222.241.172.223:8008/test"  \'请按实际升级的路径填写

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

    Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(?<=\\<BODY\\>+.+;+).+(?=\\</BODY?\\>+)")
    For i As Integer = 0 To mc.count - 1
        msgbox(mc(i).Value)
    Next
    rsps.Close
catch ex As Exception
    msgbox(ex.message)
End try


--  作者:supwork
--  发布时间:2015/7/7 14:07:00
--  
谢谢