« Win2003下安装IIS组件 图片详解ASPJPEG简要攻略之水印、缩略图和描边 »

获取来源页面的pagerank值

本程序,利用link.kuww.com的数据获得页面的pagerank值。

是asp中使用xmlhttp的一个很好的例子。

<%
Dim Str,r,p
Function GetPage(url,url2)
dim SendData,Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "post", url, False
SendData="url="&url2
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "User-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
.Send(SendData)
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Function GetContent(str,start,last,n)
If Instr(lcase(str),lcase(start))>0 then
select case n
case 0 '左右都截取(都取前面)(去处关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))-1)
case 1 '左右都截取(都取前面)(保留关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))+Len(last)-1)
case 2 '只往右截取(取前面的)(去除关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
end select
Else
GetContent=""
End if
End function

r=Request.ServerVariables("HTTP_REFERER")
str=GetPage("http://link.kuww.net/pr.asp?act=search",r)
p=GetContent(str,"在GOOGLE 上的PR值为:</font><font color=""#FF0000""><b>","</b></font></p>",0)
response.Write "document.write ("""&p&""");"
%>

原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。