标题: ASP.NET实现HTTP方式获取功能
问天
元帅
Rank: 1


元帅勋章 终身成就勋章
UID 11493
精华 187
积分 34201
帖子 33353
威望 91
金币 13148
热心 2617
阅读权限 100
注册 2006-4-7
状态 离线
ASP.NET实现HTTP方式获取功能

<%@ Assembly Name="System.Net" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
dim STRtemp as string
Sub Page_Load(Src As Object, E As EventArgs)
    Dim HttpWResp as HTTPWebresponse
    Dim sr As StreamReader
    'dim STRtemp as string
    dim build as new stringbuilder

    HttpWReq = WebRequestFactory.Create("http://www.funinspace.com")
    HttpWReq.KeepAlive = false
    HttpWResp = HttpWReq.GetResponse()
    sr = new StreamReader(HttpWResp.GetResponseStream(), Encoding.ASCII)
   
    Try
     line=sr.ReadLine()
     lineENC = server.HTMLencode(line) &;amp; vbcrlf &;amp; "<br>"
     build.append (lineENC)



    do while not IsNothing(line)
         line = sr.ReadLine()
            lineENC = server.HTMLencode(line) &;amp; vbcrlf &;amp; "<br>"
            build.append (lineENC)
    loop
    Catch ex As Exception
        problem.text =ex.Message
    End Try
   
    labelscrape.text=build.ToString()
End Sub
</script>
<html><head>
<title>Scraping A Website</title>
</head>
<body bgcolor="#FFFFFF">
<h3><font face="Verdana">Scraped Data</font></h3>
    <asp:label id=problem runat="server"/>

    <font face="courier new" size="2">


        <asp:label id=labelscrape runat="server"/>
    </font>
</body><


网友 问天 签名 - 网友社区 请您回个帖。谢谢
PR查询 免费域名 免费空间
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-12 01:00
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP