日期:2014-05-17  浏览次数:20966 次

在我的网站中输入一个网址,我想查询得到这个网址在baidu和google中的网页数量,如何实现??
在我的网站有个查询框,在里面输入一个网址,我想查询得到这个网址在baidu和google中的网页数量,如何实现??

------解决方案--------------------
以baidu为例:
<%
Function GetData(GetUrl,GetMode)
Dim Http
Set Http = Server.CreateObject( "msxml2.XMLHTTP ")
With Http
.Open "GET ",GetUrl,False
.SetRequestHeader "Referer ",GetUrl
.Send
If GetMode = 0 Then
GetData = .ResponseBody
Else
GetData = BytesToBstr(.ResponseBody, "gb2312 ")
End If
End With
Set Http =Nothing
End Function

Function BytesToBstr(Body,Cset)
Dim ADOS
Set ADOS = Server.CreateObject( "Adodb.Stream ")
With ADOS
.Type = 1
.Mode =3
.Open
.Write Body
.Position = 0
.Type = 2
.Charset = Cset
BytesToBstr = .ReadText
.Close
End With
Set ADOS = Nothing
End Function

Content = GetData( "http://www.baidu.com/s?wd=摆渡 ",1) '改这里,你应该知道怎么改的
fkey1= "找到相关网页约 "
fkey2= "篇 "
p1=instr(Content,fkey1)
p2=instr(p1,Content,fkey2)
n=mid(Content,p1+len(fkey1),p2-p1-len(fkey1))
response.Write(n)
%>