The principle of anti-collection is very simple. First, put a dynamic statement to add the visitor's IP to a table in the database. Then add a JS at the bottom of the page. The JS directly accesses the dynamic page and adds the visitor's IP to another table in the database. A table and an inside.
Yesterday I saw an anti-collection software on the Internet, which said that the collection only accesses the current web page, and does not access the pictures, JS, etc. of the web page. Today it suddenly occurred to me that the visitor's IP should be recorded through dynamic programs and JS access, and then the IP can be judged. JS will not be accessed during the collection process. During collection, only the IPs recorded by dynamic programs will be found, and there will be no IPs recorded by JS, thus preventing the collection of web page programs.
The principle of anti-collection is very simple. First, put a dynamic statement to add the visitor's IP to a table in the database. Then add a JS at the bottom of the page. The JS directly accesses the dynamic page and adds the visitor's IP to another table in the database. A table and an inside. When accessing again, read the IP data from the two tables, and then determine the time difference. If it is only found in the first table but not in the second table, or the time difference exceeds 10 seconds, it is considered to be collected.
advantage
1. Simple deployment, as long as it is a dynamic language, it can be easily implemented without the need for server-side programs.
2. It has high lethality and can block almost all collection processes.
shortcoming
1. The first disadvantage is its high lethality. If you need to use it in practice, you need to consider some special circumstances to avoid accidentally killing the search crawler.
2. Only applicable to dynamic web pages, static pages cannot be used.
The process is a bit messy, but the principle itself is not very complicated. The program example is attached below, and those who know ASP should be able to understand it quickly.
Program example (ASP+ACCESS) (test program download):
1. Create a database
Table 1: Ip1, fields Ip1_Adderss (text), Ip1_Time (date/time, default=Now())
Table 2: Ip2, fields Ip2_Adderss (text), Ip2_Time (date/time, default=Now())
2.Index.asp (only dynamic code, please see the test program for all codes)
Copy the code as follows:<%@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 (Do not collect!)
Response.End()
Else
IpTime2=Rs(Ip2_Time)
If DateDiff(s,IpTime2,IpTime)>10 Then
Rs.Close
Response.Write (Do not collect!)
Response.End()
End If
End If
Rs.Close
End If
%>
3.Js.asp
copy code is as follows:
<%
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
%>
4. Get.asp
copy code is as follows:
<%@LANGUAGE=VBSCRIPT CODEPAGE=936%>
<%
Response.Write(Server.HTMLEncode(GetHttpPage(http://localhost/Index.asp,GB2312)))
'== ============================
'Function name: GetHttpPage
'Function: Get page source code function
' Parameters: URL HttpUrl
'==============================
Function GetHttpPage(HttpUrl,Code )
If IsNull(HttpUrl)=True Or HttpUrl= Then
GetHttpPage=A site is under maintenance!
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 site Under maintenance!
Exit function
End if
GetHttpPage=BytesToBSTR(Http.responseBody,Code)
Set Http=Nothing
If Err.number<>0 then
Err.Clear
GetHttpPage=CThe site is under maintenance!
Exit function
End If
End Function
'==============================
'Function name: BytesToBstr
'Function: Convert encoding function
' parameters : String Body, encoding 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
%>
This article was originally created by Fang Ka Online, Please indicate the source when reprinting. Any similarity is purely coincidental!