Sogou rank查询 使用asp
分类: 代码 | 标签: | 日期:2007-02-12 | 1 views
在你的blog目录下新建一个sogou_pr.asp文件
加入以下代码
代码已更新
<% Dim sogouStr,r,sogoup Function GetPage(url) dim SendData,Retrieval Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "post", url, False .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() 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("r")
if r="" then r=Request.ServerVariables("HTTP_HOST")
sogoustr=GetPage("http://www.sogou.com/web?query="&r)
sogoup=GetContent(sogoustr,"<img src=""http://www.sogou.com/images/pr.gif"" width=""","%""",0)
response.Write "document.write(""
"
response.Write "
Sogou Rank
"
response.Write ""&sogoup&"
"")"
set sogouStr=nothing
set sogoup=nothing
set r=nothing
%>
然后在网页任意位置加入链接即可查询sogou rank值了
注意:使用此方法要将global.css中的
img {max-width: 100%;height: auto;}
去掉,否则会发现绿色指示条纵向溢出
更新后的代码解决了多网站调用的问题
自动获取当前网页主域名
红色部分为最近更新



支持。
[回复]
zqm852 @ 2007年07月4日
学习一下,我也弄一个。12801
[回复]
pbc824 @ 2007年09月23日