您所在的位置:小祥子 » 编程 » ASP » 正文

ASP采集小偷函数示例

时间:2015-01-30 编辑:佚名 来源:互联网
分享几个采集小偷用到的函数
<%
Function ByteToStr(vIn)
    Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
    strReturn = "" 
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn,i,1))
        IF(ThisCharCode < &H80)THEN
            strReturn = strReturn & Chr(ThisCharCode)
        ELSE
            NextCharCode = AscB(MidB(vIn,i+1,1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
            i = i + 1
        END IF
    Next
    ByteToStr = strReturn 
End Function
//获取采集页内容
Function GetHttpPageContent(url,Method,SendStr)
    Dim Retrieval
    SET Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
    With Retrieval
        .Open Method, url, False ,"" ,""
        .setRequestHeader "Content-Type","application/x-www-form-urlencoded"
        .Send(SendStr)
        GetHttpPageContent = .ResponseBody
    End With
    SET Retrieval = Nothing
    GetHttpPageContent=ByteToStr(GetHttpPageContent)
End Function
//正则匹配采集到的所需内容
Function RegExpText(strng,regStr)
    Dim regEx,Match,Matches,RetStr
    SET regEx = New RegExp
    regEx.Pattern = regStr
    regEx.IgnoreCase = True
    regEx.Global = True
    SET Matches = regEx.Execute(strng)
    For Each Match in Matches
        RetStr = RetStr & regEx.Replace(Match.Value,"$1") & "," 
    Next
    RegExpText = RetStr
    set regEx=nothing
End Function
Function StreamBytesToBstr(strBody, CodeBase)
Dim obJStream
SET objStream = Server.CreateObject("Adodb.Stream")
With objStream
    .Type = 1
    .Mode = 3
    .Open
    .Write strBody
    .Position = 0
    .Type = 2
    .Charset = CodeBase
    StreamBytesToBstr = .ReadText
    .Close
End With
SET objStream = Nothing
End Function
%>
关键词:采集 小偷 函数