.NET CSS DHTML JavaScript FlashASP PHP JSP XML
返回首页
当前位置: 主页 > 网页技术 > ASP >

我的采集类(asp)

时间:2009-12-04 16:56来源:未知 作者:admin 点击:
%Function GetPage(url) Dim Retrieval Set Retrieval = CreateObject(Microsoft.XMLHTTP) With Retrieval .Open Get, url, False, , .Send GetPage = BytesToBstr(.ResponseBody) End With Set Retrieval = Nothing End Function Function GetContent(str,st

<%Function GetPage(url)
Dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function

Function GetContent(str,start,last,n)
If Instr(lcase(str),lcase(start))>0 then
   select case n
   case 0
   Rem 左右都截取(都取前面)(去处关键字)
   GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
   GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))-1)
   case 1
   Rem 左右都截取(都取前面)(保留关键字)
   GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
   GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))+Len(last)-1)
   case 2
   Rem 只往右截取(取前面的)(去除关键字)
   GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
   end select
Else
   GetContent=""
End if
End function

Function ReplaceStr(str,start,last)
Rem str 变量名称 start 要过滤的字符 last 要替换的字符
ReplaceStr=Replace(str,start,last)
End Function

Function BytesToBstr(body)
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 = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Rem 检测是否有汉字
Function RegChinese(str)
    Dim regEx, retVal
    Set regEx = New RegExp
    regEx.Pattern = "^[^u0000-u00FF]*quot;
    regEx.IgnoreCase = False
    retVal = regEx.Test(str)
    If retVal Then
        RegChinese = True
    Else
        RegChinese = False
    End If
End Function

function rep(Str)

rep=replace(replace(replace(str,chr(34),"") ,CHR(13),""),chr(10),vbCrLf)
 

end function

%>

 

(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片
推荐内容