孤灯浪子版防采集的终极解决方案1.0

来源:互联网 发布:july 算法 编辑:程序博客网 时间:2024/04/26 12:30

<%
'================================================================
'======作  者:孤灯浪子
'======版  本:1.0
'======联系方式:QQ 22545048 Email:gudenglangzi(a)163.com MSN:GUDENGLANGZI(a)MSN.COM
'======功能说明:应对采集是很多网站最为头疼的问题,虚高的流量,沉重的服务器负担,怎么样才能让那些无耻的采集者们见他妈的鬼去呢?
'============== 如果封IP,它们使用代理;而且正常访问的人也不能使用;目前使用ADSL上网,它们只是断线后重连,我们也无计可施,封一段IP对一个网站的真正用户来说是非常不公平的。
'============== 听之任之,网站访问流量很大,都被那些信息采集的家伙占去了。
'============== 使用权限,搜索引擎的搜不到东西,现代社会,面向用户和面向搜索引擎同样重要,或者面向搜索引擎更重要。
'============== 使用全局统一变量,访问非常不友好,看到那一坨屎的长码,就恶心。
'============== 使用延时的方式,这是最流行的方式,真正的用户才不喜欢这个功能呢,让人感觉到网站管理者的黔驴技穷。
'============== 本人试图解决这个问题,就有了下面的一段代码,虽然不是万能的,但较之现在网络上许多流行的限制时间的代码还有友好一些。
'============== 本来想封装成类或者函数,刚刚写出来,调试成功的东西就想和大家分享,等不及了。
'======实现说明:危险的ip组成ip库,当这些ip访问网站的时候,先让他们计算一个题目,答案正确者,允许访问,答案错误者,让他们到百度上为我们增加一次搜索吧。
'============== 具体的变量就不再说明,稍微不忙的时候我再细化吧。
'======版权说明:引用的时候加上这个头就可以,谢谢了。
'======友情访问:本人正在起点连载长篇武侠小说《小倩》,欢迎访问。
'============== http://www.cmfu.com/showbook.asp?bl_id=91527
'================================================================


'设置重新验证时间,单位分钟。您可以把这个拿到global.asa中使用
application("time_belimit_width")=3


'验证访问者的ip是否在危险ip库响
if instr("58.61.164.140,58.61.164.138,58.61.164.139,58.61.164.141,58.61.164.142,219.135.238.224,122.0.194.122,58.61.90.0,221.218.239.53,220.181.19.164,219.135.238.224,219.235.240.136,219.235.240.136,202.106.182.157,61.140.123.146,",request.ServerVariables("REMOTE_ADDR")&",") then

  '如果记录起始瞬间的cookie time_belimit_start为空,先置值,这是为了下面能正常使用
  if request.cookies("time_belimit_start")="" then
   response.cookies("time_belimit_start")=(now()-application("time_belimit_width")*0.001)
  end if

  '如果记录答案的cookie limitresult为wrong或者现在已经超过了前面定义的时长,才去执行算式验证
  if request.cookies("limitresult")="wrong" or abs(minute(now())-minute(FormatDateTime(request.cookies("time_belimit_start"))))>application("time_belimit_width") then
  
   '设置cookie limitresult的初始值为wrong
   response.cookies("limitresult")="wrong"
   '设置起始时间为现在
   response.cookies("time_belimit_start")=now()


   '取得随机数和随机数的和
   randomize
   belimit_first=Int((9 - 0 + 1) * Rnd + 1)
   randomize
   belimit_second=Int((9 - 0 + 1) * Rnd + 1)
   belimit_result=belimit_first+belimit_second
   
   '提示验证信息
   word_belimit_1="对不起,您所在ip段曾经存在恶意抓取我们网页的行为,我们不得已采取授权访问制."&_
       "请根据提示回答问题,结果正确,您可以在"&application("time_belimit_width")&"分钟内正常访问,结果错误,您将无法正确访问。"
   response.write(word_belimit_1 & "您访问的开始时间是:"&request.cookies("time_belimit_start"))
   
   '设定表达式
   word_belimit= "请问"&belimit_first&"+"&belimit_second&"="
   
   
   response.write("<script language='javascript'>")
   
    response.write("var word_in;")
    response.write("word_in=prompt('" & word_belimit & "');")
    response.write("document.write(word_in);")
    response.write(" if(word_in!="&belimit_result&")")
    response.write(" {")
    response.write("  document.write('回答错误,谢谢使用。');")
   
    '答案错误,转向百度搜索
    response.write("  document.location.href='http://www.baidu.com/s?wd=%C3%BF%C8%D5%C8%CB%B2%C5%CD%F8&cl=3';")
    response.write(" }")
    response.write(" else")
    response.write(" {")

    '答案正确,设置cookie limitresult为“success”
    response.write("  document.cookie='limitresult=success';")
    response.write(" }")
    
   response.write("</script>")
   
  end if

end if

 

%>

 

 
原创粉丝点击