精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

ASP采集程序中的字符串截取函数,功能比较多,可指定截取范围,你只需要自定义开始字符串、结束字符串即可,另还还可指定截取的字符串中是否包含开始字符串和结束字符串。

ASP截取采集网页指定内容函数参数说明

ConStr ------将要截取的字符串

StartStr ------开始字符串

OverStr ------结束字符串

IncluL ------是否包含

StartStrIncluR ------是否包含OverStr

ASP截取采集网页指定内容函数

Function GetBody(ConStr,StartStr,OverStr,IncluL,IncluR)
If ConStr="$False$" or ConStr="" or IsNull(ConStr)=True Or StartStr="" or IsNull(StartStr)=True Or OverStr="" or IsNull(OverStr)=True Then
GetBody="$False$"
Exit Function
End If
Dim ConStrTemp
Dim Start,Over
ConStrTemp=Lcase(ConStr)
StartStr=Lcase(StartStr)
OverStr=Lcase(OverStr)
Start = InStrB(1, ConStrTemp, StartStr, vbBinaryCompare)
If Start<=0 then
GetBody="$False$"
Exit Function
Else
If IncluL=False Then
Start=Start+LenB(StartStr)
End If
End If
Over=InStrB(Start,ConStrTemp,OverStr,vbBinaryCompare)
If Over<=0 Or Over<=Start then
GetBody="$False$"
Exit Function
Else
If IncluR=True Then
Over=Over+LenB(OverStr)
End If
End If
GetBody=MidB(ConStr,Start,Over-Start)
End Function
Tags:ASP 采集 函数