可以查询google排名的asp源码
程序员文章站
2023-11-20 20:15:16
以下是源码,请命名为.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 <> "" 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, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ") '
fstring = replace(fstring, chr(9), " ") '
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(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>
复制代码 代码如下:
<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, ">", ">")
fstring = replace(fstring, "<", "<")
fstring = replace(fstring, chr(32), " ") '
fstring = replace(fstring, chr(9), " ") '
fstring = replace(fstring, chr(34), """)
fstring = replace(fstring, chr(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>