分享你我的心得.
共乘一片美好网络.

网页防采集代码(asp,javascript)

防止一般的采集以及小偷读取,加在顶部。
方法一、防采集的asp代码
<%
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 "歇一会儿吧!整天采集你烦不烦啊!"
response.end
End If
%>

方法二、

防采集的JS代码

<script language="JavaScript" type="text/javascript">
// Example:

// writeCookie("myCookie", "my name", 24);

// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

function writeCookie(name, value, hours)

{

var expire = "";

if(hours != null)

{

expire = new Date((new Date()).getTime() + hours * 3600000);

expire = "; expires=" + expire.toGMTString();

}

document.cookie = name + "=" + escape(value) + expire;

}

// Example:

// alert( readCookie("myCookie") );

function readCookie(name)

{

var cookieValue = "";

var search = name + "=";

if(document.cookie.length > 0)

{

offset = document.cookie.indexOf(search);

if (offset != -1)

{

offset += search.length;

end = document.cookie.indexOf(";", offset);

if (end == -1) end = document.cookie.length;

cookieValue = unescape(document.cookie.substring(offset, end))

}

}

return cookieValue;

}

</script>

方法三、

<%
‘作用:文字防复制乱码 函数
‘Date:2006-3-6
‘参数str 为原文,str1作者也是你自己,reslut产生乱码的种子
Function ReadToCode(str,Str1,result)
dim name
dim i,j,k
If isnull(str) then
ReadToCode=""
Exit Function
End If
Randomize
k=instr(str,"</P>")
Do while k>0
result=""
for i=0 to 19
j=Int(128 * Rnd)+1
if j=60 or j=62 then
j=j+1
end if
result =result&chr(j) ‘ 产生随机数。
next
result="<span style=’DISPLAY: none’>"&result&"</span>"
str=replace(str,"</p>",result&"<‘/p>",1,1)
k=instr(str,"</p>")
loop
str=replace(str,"<‘/p>","</p>")

k=instr(str,"<br>")
Do while k>0
result=""
for i=0 to 19
j=Int(128 * Rnd)+1
if j=60 or j=62 then
j=j+1
end if
result =result&chr(j) ‘ 产生随机数。
next
result="<span style=’DISPLAY: none’>"&result&"</span>"
str=replace(str,"<br>",result&"<‘br>",1,1)
k=instr(str,"<br>")
loop
str=replace(str,"<‘br>","<br>")
ReadToCode=str&"<div align=right style=’color=gray’>[版权归原作者及"&Str1&"共同拥有,转载请注明出处]</div>"
End Function

‘Dim a
a="<p>嘎嘎<br>一篇不错的好文章哦</p>"

‘Only For Test
‘response.write (a)

Dim b
‘为配合转换,字符串a的大小都替换成小写
b=ReadToCode(LCase(a),"本网","www.yiqixue.com")

‘Output
response.write b
%>
 

赞(0)
未经允许不得转载:小叶白龙博客 » 网页防采集代码(asp,javascript)

评论 39

登录

找回密码

注册