asp動態網頁面防採集的新方法

來源:互聯網
上載者:User

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Response.Write(Server.HTMLEncode(GetHttpPage("http://localhost/Index.asp教程","GB2312")))
==============================
函 數 名:GetHttpPage
作 用:擷取頁面原始碼函數
參 數:網址HttpUrl
==============================
Function GetHttpPage(HttpUrl,Code)
If IsNull(HttpUrl)=True Or HttpUrl="" Then
GetHttpPage="A網站維護中!"
Exit Function
End If
On Error Resume Next
Dim Http
Set Http=server.createobject("MSX"&"ML2.XML"&"HTTP")
Http.open "GET",HttpUrl,False
Http.Send()
If Http.Readystate<>4 then
Set Http=Nothing
GetHttpPage="B網站維護中!"
Exit function
End if
GetHttpPage=BytesToBSTR(Http.responseBody,Code)
Set Http=Nothing
If Err.number<>0 then
Err.Clear
GetHttpPage="C網站維護中!"
Exit function
End If
End Function
==============================
函 數 名:BytesToBstr
作 用:轉換編碼函數
參 數:字串Body,編碼Cset
==============================
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("ado"&"d"&"b.st"&"re"&"am")
Objstream.Type = 1
Objstream.Mode =3
Objstream.Open
Objstream.Write body
Objstream.Position = 0
Objstream.Type = 2
Objstream.Charset = Cset
BytesToBstr = Objstream.ReadText
Objstream.Close
set Objstream = nothing
End Function
%>
<%
Dim Conn,Rs,Sqlstr,Ip
Set Conn = Server.CreateObject("Adodb.Connection")
Set Rs=Server.Createobject("Adodb.RecordSet")
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Data.mdb")
Conn.Open ConnStr
Ip=Request.ServerVariables("REMOTE_ADDR")
Sqlstr="Select * From [Ip2]"
Rs.Open Sqlstr,Conn,1,3
Application.Lock()
Rs.AddNew()
Rs("Ip2_Address")=Ip
Rs.Update()
Application.UnLock()
Rs.Close
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Dim Conn,Rs,Sqlstr,Ip,IpTime,IpTime2,NewUser
NewUser=0
Set Conn = Server.CreateObject("Adodb.Connection")
Set Rs=Server.Createobject("Adodb.RecordSet")
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Data.mdb")
Conn.Open ConnStr
Ip=Request.ServerVariables("REMOTE_ADDR")
Sqlstr="Select * From [Ip1] Where Ip1_Address='"&Ip&"' Order By Ip1_Id Desc"
Rs.Open Sqlstr,Conn,1,3
If Rs.Eof Then
NewUser=1
Application.Lock()
Rs.AddNew()
Rs("Ip1_Address")=Ip
Rs.Update()
Application.UnLock()
Else
IpTime=Rs("Ip1_Time")
Application.Lock()
Rs.AddNew()
Rs("Ip1_Address")=Ip
Rs.Update()
Application.UnLock()
End If
Rs.Close
If NewUser=0 Then
Sqlstr="Select * From [Ip2] Where Ip2_Address='"&Ip&"' Order By Ip2_Id Desc"
Rs.Open Sqlstr,Conn,1,3
If Rs.Eof Then
Rs.Close
Response.Write("請勿採集!")
Response.End()
Else
IpTime2=Rs("Ip2_Time")
If DateDiff("s",IpTime2,IpTime)>10 Then
Rs.Close
Response.Write("http://www.3lian.com/教程提示你,請採集!")
Response.End()
End If
End If
Rs.Close
End If
%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.