内容显示页
 
类别:ASP+VBS | 浏览(99) | 2008-1-1 11:59:35

 

'/*=========================================================================
' * Intro       VBS实现搜索引擎收录数查询-学VBS采集或正则表达式的可以看看
' * FileName    GetSearchCount.vbs
' * Author      yongfa365
' * Version     v1.1
' * WEB         http://www.yongfa365.com
' * Email       yongfa365[at]qq.com
' * FirstWrite  http://www.yongfa365.com/Item/GetSearchCount.vbs.html
' * MadeTime    2008-01-01 11:54:04
' * LastModify  2008年3月3日 15时20分44秒
' *==========================================================================*/
on error resume next
weburl = InputBox("查询的网址", "查询的网址", "http://www.yongfa365.com")
weburl = Replace(weburl, "http://", "")
NO_baidu = getContents("找到相关网页约*(.+?)篇", getHTTPPage("http://www.baidu.com/s?wd=site:" & weburl, "GB2312"), TRUE)(0)
NO_google = getContents("<b>(.+?)</b>", getHTTPPage("http://www.google.cn/search?q=site:" & weburl, "utf-8"), TRUE)(0)
NO_yahoo = getContents("共 <strong>(.+?)</strong> 条", getHTTPPage("http://sitemap.cn.yahoo.com/search?p=" & weburl, "utf-8"), TRUE)(0)
NO_live = getContents("(共 (.+?) 条)", getHTTPPage("http://cnweb.search.live.com/results.aspx?q=site:" & weburl, "utf-8"), TRUE)(0)
NO_sogou = getContents("找到 (.+?) 个网页", getHTTPPage("http://www.sogou.com/web?query=site:" & weburl, "GB2312"), TRUE)(0)
Str = Str & vbCrLf & "baidu: " & NO_baidu
Str = Str & vbCrLf & "google:" & NO_google
Str = Str & vbCrLf & "yahoo: " & NO_yahoo
Str = Str & vbCrLf & "live:  " & NO_live
Str = Str & vbCrLf & "sogou: " & NO_sogou
MsgBox Str



'<---------------------------------------XMLHTTP------------------------------------->

Function getHTTPPage(Path, CodePage)
    t = GetBody(Path)
    getHTTPPage = BytesToBstr(t, CodePage)
End Function

Function GetBody(url)
    On Error Resume Next
    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
    With xmlhttp
        .Open "Get", url, False
        .Send
        .waitForResponse 1000
        GetBody = .ResponseBody
    End With
    Set xmlhttp = Nothing
End Function

Function BytesToBstr(Body, Cset)
    On Error Resume Next
    Dim objstream
    Set objstream = 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


'<---------------------------------------/ XMLHTTP------------------------------------->

'得到匹配的内容,并以数据形式显示
'表达式,字符串,是否返回引用值
'msgbox getContents("a(.+?)b", "a23234b ab a67896896b sadfasdfb" ,True)(0)

Function getContents(patrn, strng , yinyong)
    Dim re, Matches, i, oMatch
    Set re = New RegExp
    re.Pattern = patrn
    re.IgnoreCase = True
    re.Global = True
    Set Matches = re.Execute(strng)
    If yinyong Then
        For i = 0 To Matches.Count -1
            If Matches(i).Value<>"" Then RetStr = RetStr & Matches(i).SubMatches(0) & "柳永法"
        Next
    Else
        For Each oMatch in Matches
            If oMatch.Value<>"" Then RetStr = RetStr & oMatch.Value & "柳永法"
        Next
    End If
    getContents = Split(RetStr, "柳永法")
End Function

 


引用本页地址:http://www.yongfa365.com/item/GetSearchCount.vbs.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片看不清? 换张图试试
 
   
 
 
文章分类
 
 
专题(3)
 
ASP+VBS(141)
 
 
 
 
Linux(10)
 
 
SQL(55)
 
web 2.0(22)
 
 
 
 
 
 
心程(48)
 
生活(71)
 
创业(5)
 
   

power by :柳永法(yongfa365)'Blog | model by :hibaidu | css by:众网友 | 京ICP备07011491号   我要统计  

本空间赞助商:北京中科兴联信息技术有限公司

QQ:64049027    E-mail:64049027<at>qq.com