首页 > 编程 > .NET > 正文

使用net classes访问其他网站内容

2024-07-21 02:16:57
字体:
来源:转载
供稿:网友
<script language="vb" runat="server">
sub page_load(src as object, e as eventargs)
    try
        dim objresponse as system.net.webresponse
        dim objrequest as system.net.webrequest
        dim theurlresult as string
        dim theurl as string = "http://www.funinspace.com"
        objrequest = system.net.httpwebrequest.create(theurl)
        objresponse = objrequest.getresponse()
        dim sr as new system.io.streamreader(objresponse.getresponsestream())
        theurlresult=server.htmlencode(sr.readtoend())
        page.controls.add(new literalcontrol(theurlresult))
    catch ex as exception
        page.controls.add(new literalcontrol(ex.message))
    end try
end sub
</script>
<html><head>
<title>scraping a website</title>
</head>
<body bgcolor="#ffffff">
<h3><font face="verdana">scraped data</font></h3>

</body></html>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表