Foxtable(狐表)用户栏目专家坐堂 → 请教如何获取网页内容


  共有2261人关注过本帖树形打印复制链接

主题:请教如何获取网页内容

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By: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


 回到顶部