加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

能查询google排名的asp源码

发布时间:2023-08-16 13:29:01 所属栏目:Asp教程 来源:
导读:以下是源码,请命名为.ASP文件.代码如下:<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <% if request("action") = "1" then word = request("word") url = request("url") if word <

以下是源码,请命名为.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") 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章