Yesterday I saw an anti-capture software on the Internet, said acquisition only access to the current page, will not visit the Web page pictures, JS, and so on, today suddenly thought, through the dynamic program and JS access to record the IP of the visitors, and then IP judgment, as the acquisition process will not visit JS, collection will only be found with dynamic program recorded IP , and will not have through JS recorded IP, so as to achieve the Web page program to prevent collection.
Anti-collection principle is very simple, first put a dynamic statement, the visitor's IP into a database table, and then add a js,js at the bottom of the page directly access the dynamic page, the visitor's IP to add to the database of another table. Once again visit, read IP data from two table, then Judge time difference, if only found in the first table, in the second table can not find, or time difference more than 10 seconds, it is considered to be collected.
Advantages
1. Simple deployment, as long as the dynamic language can be easily implemented without the help of server-side programs
2. Large lethality, can almost kill all the collection process
Disadvantages
1. The first shortcoming is still large, if the need for practical use need to consider some special circumstances, lest manslaughter has killed the search crawler
2. Only apply to Dynamic Web pages, static pages can not be used
The process of writing more messy, but the principle itself is not very complex, the following attached to the program examples, understand the ASP should be able to understand quickly.
This article by the Square Card online (http://www.fangka.net/) original, reprint please indicate the source. If there is similarity, it is a coincidence!
program Example (asp+access) (test program Download):
1. Establishing a Database
Table 1:ip1, field ip1_adderss (text), Ip1_time (Date/time, default value =now ())
Table 2:ip2, field ip2_adderss (text), Ip2_time (Date/time, default value =now ())
2.index.asp (dynamic code only, all code see test program)
<% @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
<%
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
<% @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 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 maintenance! "
Exit function
End If
Gethttppage=bytestobstr (Http.responsebody,code)
Set http=nothing
If Err.number<>0 Then
Err.Clear
Gethttppage= "C Site maintenance! "
Exit function
End If
End Function
'==============================
' Function name: bytestobstr
' Function: Converting encoded functions
' 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
%>