可以查询google排名的asp源码

所属分类: 网络编程 / ASP编程 阅读数: 1192
收藏 0 赞 0 分享
以下是源码,请命名为.ASP文件.

复制代码 代码如下:

<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<% 
if request("action") = "1" then 
 word = request("word") 
 url = request("url") 
 if word <> "" then 
  getCategories() 

  if url <> "" then 
   getCategories2() 
  end if 
 end if 
end if 

Function getCategories() 

response.write("<b>'"&word&"' 关键词在Google搜索排名中,前10位网站!</b><br>") 

on error resume next 
Dim oXMLHTTP  
Dim oCategories  
Dim BodyText 
Dim Pos,Pos1 
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP") 
http = "http://www.google.com/search?q="&word&"&hl=zh-CN" 
oXMLHTTP.open "GET",http,False   
oXMLHTTP.send  

 BodyText=oXMLHTTP.responsebody 
 BodyText=BytesToBstr(BodyText,"UTF-8") 
 Pos=Instr(BodyText,"<body") 
 pos1=Instr(BodyText,"</body>") 
 BodyText=mid(BodyText,pos,pos1) 

 Pos = Instr(BodyText,"<div>") 
 BodyText = Mid(BodyText,Pos) 
 pos1=Instr(BodyText,"</div>") 
 BodyText=mid(BodyText,1,pos1) 
 'response.write ("::::"&BodyText&"::::") 

 BodyText=split(BodyText,"<p class=g>") 

 for i = 1 to 10 
  Pos=Instr(BodyText(i),"</a>") 
  thet = Mid(BodyText(i),1,Pos+3)  

  Pos = Instr(BodyText(i),"<span dir=ltr>") 
  theu = Mid(BodyText(i),Pos) 
  pos1=Instr(theu,"</span>") 
  theu=mid(theu,1,pos1-1) 

  response.write("T:"&thet&"<br>") 
  response.write("U:"&theU&"<br><hr>") 

 next 

Set oXMLHTTP = Nothing  
if err.number<>0 then 
response.write "出错了,错误描述:"&err.description & "<br>错误来源"& err.source 
response.End() 
end if 
End Function  


Function getCategories2() 
on error resume next 
Dim oXMLHTTP ' As Object 
Dim oCategories ' As Object 
Dim BodyText 
Dim Pos,Pos1 
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP") 

out = 0 
start = 0 
pp = 0 
do while(true) 

strurl="http://www.google.com/search?q="&word&"&hl=zh-CN&start="&start 
'response.write(strurl&"<br>") 

oXMLHTTP.open "GET",strurl,False   
oXMLHTTP.send  

 BodyText=oXMLHTTP.responsebody 
 BodyText=BytesToBstr(BodyText,"gb2312") 
 Pos=Instr(BodyText,"<body") 
 pos1=Instr(BodyText,"</body>") 
 BodyText=mid(BodyText,pos,pos1) 


 Pos = Instr(BodyText,"<div>") 
 BodyText = Mid(BodyText,Pos) 
 pos1=Instr(BodyText,"</div>") 
 BodyText=mid(BodyText,1,pos1) 
 'response.write ("::::"&BodyText&"::::") 

 BodyText=split(BodyText,"<p class=g>") 

 for i = 1 to 10 
  Pos = Instr(BodyText(i),"<span dir=ltr>") 
  theu = Mid(BodyText(i),Pos) 
  pos1=Instr(theu,"</span>") 
  theu=mid(theu,1,pos1-1) 
  'response.write(theu) 

   Pos3=Instr(theu,url) 
  if Pos3 > 0 then 
   pp = start + i 
   out = 1 
   Exit For 
  end if 
 next 

 if out = 1 or start = 90 then 
  exit do 
 end if 

 start = cint(start)+10 
loop 
if pp <> 0 then 
 response.write("<br><br>网站 <b>'"&url&"'</b> 在搜索关键词 <b>'"&word&"'</b> 时在Google中排名名次 第<b> "&pp&" </b>位 ") 
else 
 response.write("<br><br>网站 <b>'"&url&"'</b> 在搜索关键词 <b>'"&word&"'</b> 时在Google中排名名次 <font color=red>未在前100名内</font>") 
end if 


Set oXMLHTTP = Nothing  
if err.number<>0 then 
response.write "出错了,错误描述:"&err.description & "<br>错误来源"& err.source 
response.End() 
end if 

End Function  

Function BytesToBstr(body,Cset) 
        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 = Cset 
        BytesToBstr = objstream.ReadText  
        objstream.Close 
        set objstream = nothing 
End Function 
Public Function HTMLEncode(fString) 
  If Not IsNull(fString) Then 
   fString = replace(fString, ">", "&gt;") 
   fString = replace(fString, "<", "&lt;") 
   fString = Replace(fString, CHR(32), " ")  '&nbsp; 
   fString = Replace(fString, CHR(9), " ")   '&nbsp; 
   fString = Replace(fString, CHR(34), "&quot;") 
   fString = Replace(fString, CHR(39), "&#39;") '单引号过滤 
   fString = Replace(fString, CHR(13), "") 
   fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ") 
   fString = Replace(fString, CHR(10), "<BR> ") 
   HTMLEncode = fString 
  End If 
 End Function 




%> 
<title>关键字,网站在Google中排名查询</title> 
<hr><hr><b> 
关键字,网站在Google中排名查询: 
<form name="form1" method="post" action="?action=1"> 
  网址: 
    <input type="text" name="url"> 
 关键字 
 <input type="text" name="word"> 
  <input type="submit" name="Submit" value="提交"> 
</form> 
<b> 

<script> 
<!-- 
function ss(w,id){window.status=w;return true;} 
function cs(){window.status='';} 
function clk(url,ct,cd,sg){if(document.images){var u="";if (url) u="&url="+escape(url).replace(/\+/g,"%2B");new Image().src="/url?sa=T&ct="+escape(ct)+"&cd="+escape(cd)+u+"&ei=r9vyQ9ypE5GsoQKL4KDyCg"+sg;}return true;} 
function ga(o,e) {if (document.getElementById) {var a = o.id.substring(1); var p = "", r = "", t, f, h;var g = e.target;if (g) { t = g.id;f = g.parentNode;if (f) {p = f.id;h = f.parentNode;if (h)r = h.id;}} else {h = e.srcElement;f = h.parentNode;if (f)p = f.id;t = h.id;}if (t==a || p==a || r==a)return true;document.getElementById(a).href += "&ct=bg";window.open(document.getElementById(a).href,'nw')}} 
//--> 
</script> 
更多精彩内容其他人还在看

asp知识整理笔记4(问答模式)

这是关于asp知识整理的最后一份笔记,希望大家仔细阅读。
收藏 0 赞 0 分享

ASP基础知识VBScript基本元素讲解

这篇文章主要介绍了ASP基础知识VBScript基本元素的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP编码和解码函数详解

这篇文章主要介绍了ASP编码和解码函数的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP显示页面执行时间的方法

这篇文章主要介绍了ASP显示页面执行时间的方法,在本地测试一下输出页面需要多少时间,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第一篇(ASP技术简介)

本文将以 Active Server Pages 为中心,向你全面展示制作动态商业网站的步骤和技巧并通过大量的实例,让你在不断的理论和实践之中笑傲“网络”……
收藏 0 赞 0 分享

ASP基础入门第二篇(ASP基础知识)

这篇文章是ASP基础入门第二篇,第一篇展示了ASP动态网站设计的一些最基本的方法,相信通过实践各位对 ASP 已经有了最基本的了解,本文将进一步介绍ASP动态网站的一些基本技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第三篇(ASP脚本基础)

通过前两篇的学习,相信各位已经对 ASP 的动态网站设计有了一个基本的概念和整体的印象。从本篇开始作者将从脚本语言的使用着手,由浅入深地带领大家探索 ASP 动态网站设计的真正奥秘。
收藏 0 赞 0 分享

ASP基础入门第四篇(脚本变量、函数、过程和条件语句)

大家在学习了脚本语言 VBScript 的变量、常量和过程的基本概念后,本期将继续向各位介绍 VBScript 的函数和语法。
收藏 0 赞 0 分享

ASP基础入门第五篇(ASP脚本循环语句)

在本文上两篇中,我们学习了脚本语言 VBScript 的变量、函数、过程和条件语句,本篇将继续给大家介绍 VBScipt 的循环语句,并对脚本语言在 ASP 中的应用加以总结。  
收藏 0 赞 0 分享

ASP基础入门第六篇(ASP内建对象Request)

从本篇开始作者从 ASP 内建对象着手,为大家详细剖析 ASP 的六个内建对象和各种组件的特性和方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多