使用cookie简单实现asp防采集
下面这段防采集asp代码采用了cookie来实现,适合新手来学习。
vb 代码
- <%
- Dim AppealNum,AppealCount
- AppealNum=10 '同一IP60秒内请求限制10次
- AppealCount=Request.Cookies("AppealCount")
- If AppealCount="" Then
- response.Cookies("AppealCount")=1
- AppealCount=1
- response.cookies("AppealCount").expires=dateadd("s",60,now())
- Else
- response.Cookies("AppealCount")=AppealCount+1
- response.cookies("AppealCount").expires=dateadd("s",60,now())
- End If
- if int(AppealCount)>int(AppealNum) then
- response.write "海波吧 www.haibor8.cn提醒您:采集抓取是很累,咱歇一会儿吧!"
- response.end
- End If
- %>