使用cookie简单实现asp防采集

下面这段防采集asp代码采用了cookie来实现,适合新手来学习。

vb 代码
 
  1. <%
  2. Dim AppealNum,AppealCount
  3. AppealNum=10 '同一IP60秒内请求限制10次
  4. AppealCount=Request.Cookies("AppealCount"
  5. If AppealCount="" Then
  6. response.Cookies("AppealCount")=1
  7. AppealCount=1
  8. response.cookies("AppealCount").expires=dateadd("s",60,now())
  9. Else
  10. response.Cookies("AppealCount")=AppealCount+1
  11. response.cookies("AppealCount").expires=dateadd("s",60,now())
  12. End If
  13. if int(AppealCount)>int(AppealNum) then
  14. response.write "海波吧 www.haibor8.cn提醒您:采集抓取是很累,咱歇一会儿吧!"
  15. response.end
  16. End If
  17. %>