如何用
PHP 和
ASP 跨站抓取別的站點的頁面,今天我們來測試一下 ASP+
是怎麼實現 跨站抓取 別的站點的頁面
Code Listing
<%@ Assembly Name="System.Net" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<scr
ipt language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim HttpWResp as HTTPWebresponse
Dim sr As StreamReader
dim STRtemp as string
text1.text = ""
HttpWReq = WebRequestFactory.Create("http://www.ASP888.Net")
HttpWReq.KeepAlive = false
HttpWResp = HttpWReq.GetResponse()
sr = new StreamReader(HttpWResp.GetResponseStream(), Encoding.ASCII)
Try
line=sr.ReadLine()
do while line <> null
line = sr.ReadLine()
lineENC = server.Htmlencode(line) & vbcrlf & "<br>"
text1.text = text1.text & lineENC
loop
Catch ex As Exception
text1.text = "發生錯誤: " & ex.Message
End Try
End Sub
</script>
<Html><head>
<title>跨站</title>
</head>
<body bgcolor="#FFFFFF">
<h3><font face="Verdana">抓來得數據</font></h3>
<ASP:TextBox id="text1" Width="600px" Textmode="multiline" rows="40"
runat="server"/>
</body></Html>