以前寫過一個網頁小偷程式,是ASP版的
http://aowind.cnblogs.com/archive/2005/07/16/193858.html
今天看到.net裡的WEBCLIENT,試試了它的方法等,發現很好用,就用它改成了以前ASP版的網頁小偷,寫成ASP.net版的了,嘿嘿!
Imports System.net
Imports System.io
Public Class WebForm1Class WebForm1
Inherits System.Web.UI.Page
Public web As New WebClient
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'讀網頁源檔案先
If Session("aaa") = "" Then
Dim str As Stream
str = web.OpenRead("http://www.023ehouse.com")
Dim read As New StreamReader(str, System.Text.Encoding.GetEncoding("GB2312"))
Dim html As String = read.ReadToEnd()
'接下來當然是分析源檔案,提出自己要用的了
Dim aaa, bbb, ccc '這裡定義的都是用來處理結果的,要把中間自己要用的新聞給截取出來
aaa = CStr(html)
bbb = Split(aaa, "<div id=""onlinemb_05"">")
aaa = bbb(1)
ccc = Split(bbb(1), "</div>")
aaa = ccc(0)
'這裡是把新聞地址轉到自己的新聞顯示頁面,把本來的新聞地址當參數傳給頁面
aaa = Replace(aaa, "href=""", "href=""newsshow.asp?url=http://www.023ehouse.com/")
aaa = Replace(aaa, "target=""_blank""", "")
'這裡就是寫session了
Session("aaa") = aaa
End If
'最後把處理好的輸出
Response.Write(Session("aaa"))
End Sub
End Class
其實這裡就是看WEBCLIENT的用處了,