百度原创保护功能如何实现asp的post提交

近期百度站长平台推出了网站原创保护计划,里面提到了curl,post,PHP,ruby推送方式,这里针对POST方式如何用ASP来实现,百度代码示例:

POST /urls?site=http://www.xxx.com/&token=xxx&type=original HTTP/1.1
User-Agent: curl/7.12.1 
Host: data.zz.baidu.com 
Content-Type: text/plain 
Content-Length: 83 

http://www.example.com/1.html
http://www.example.com/2.html

asp语法如下,假设为post.asp,本页面示例一次只能执行一行网址提交。

<%@ CODEPAGE=65001 %>
<% Response.CodePage=65001%>
<% Response.Charset="UTF-8" %><%
server.scriptTimeOut = 300
function cut(value_,head,bot) '裁剪前后参数分别是首字符串,尾字符串
	if instr(value_ , head)>0 and instr(value_ , bot)>0 then
			newvalue=mid(value_ ,instr(value_ ,head)+len(head),instr(value_ ,bot)-instr(value_ ,head)-len(head))
		else
			newvalue= "error"
		end if
	cut=newvalue
end function
today=formatdatetime(now(),2)
posturl=dillparam(request("url"))
if len(posturl)<27 then
response.Write("error,no len")
response.End()
end if
if left(posturl,7)<>"http://" then
response.Write("start code is error")
response.End()
end if
url = "http://data.zz.baidu.com/urls?site=http://www.xxx.com/&token=xxx&type=original"
SoapRequest=""&posturl&""


Set xmlhttp = server.CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "text/plain; charset=utf-8"
xmlhttp.setRequestHeader "Content-Length",LEN(SoapRequest)
xmlhttp.Send(SoapRequest)
'这样就利用XMLHTTP成功发送了请求.
'检测一下是否成功:
'Response.Write xmlhttp.Status & "<br>"'成功的话是200
itext=xmlhttp.responsetext
Set xmlhttp = Nothing
outPrint = cut(itext,"{","}")
response.Write(outPrint)
%>

假设浏览器执行post.asp地址在 http://www.suangu.com/post.asp?url=你提交的网址

执行后的效果

1.jpg

2017/6/30 13:07:00 技术杂谈