以前写过一个网页小偷程序,是ASP版的
http://aowind.cnblogs.com/archive/2005/07/16/193858.html
今天看到.net里的WEBCLIENT,试试了它的方法等,发现很好用,就用它改成了以前ASP版的网页小偷,写成ASP.net版的了,嘿嘿!
http://aowind.cnblogs.com/archive/2005/07/16/193858.html
今天看到.net里的WEBCLIENT,试试了它的方法等,发现很好用,就用它改成了以前ASP版的网页小偷,写成ASP.net版的了,嘿嘿!
Imports
System.net
Imports System.io
Public Class WebForm1
Inherits System.Web.UI.Page
Public web As New WebClient
Private 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的用处了,Imports System.io
Public Class WebForm1
Inherits System.Web.UI.Page
Public web As New WebClient
Private 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