当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > ASP.NET实现HTTP方式获取功能

ASP.NET
简单Web service 身份验证解决方案
asp.net SQL存储过程分页
asp.net 虚拟主机时常出现MAC验证失败错误之解决方法
ASP.net(c#) 生成html的几种解决方案[思路]
asp.net 生成静态页时的进度条显示
asp.net Coolite 学习交流
Coolite Cool Study 1 在Grid中用ComboBox 来编辑数据
Coolite Cool Study 2 同时更新多个Tab
Coolite Cool Study 3 MVC + Coolite 的实现代码
CommunityServer又称CS论坛的相关学习资料
C# 给站点指定位置的某种格式的图片添加水印
C# 添加文字水印类代码
asp.net 纯真ip库取得所在地实现代码
.NET 动态编译
C# 动态编译、动态执行、动态调试
asp.net 实现自定义Hashtable (.net)
asp.net 2.0的文件上传(突破上传限制4M)
C# OWC生成图表
asp.net javascript 文件无刷新上传实例代码
ASP.net 路径问题 详细说明

ASP.NET实现HTTP方式获取功能


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 38 ::
收藏到网摘: n/a

<%@ 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) & vbcrlf & "<br>"
build.append (lineENC)

do while not IsNothing(line)
line = sr.ReadLine()
lineENC = server.HTMLencode(line) & vbcrlf & "<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></html>