您当前的位置: 首页 > 网站编程 > ASP教程 > Asp开发的可以用来做采集与分析html代码的类

Asp开发的可以用来做采集与分析html代码的类

作者:不详 来源:网络 发布时间: 2011-10-14 11:53 点击:
本文发布的是用Asp开发的可以用来做采集与分析html代码的类,大家有兴趣可以参考,可以在此基础上能做出好多东东呢! % Dim mySpider,MyConn,IsConnection IsConnection=False Set mySpider=New ClsProcess Class ClsProcess Private CacheName,Reloadtime,LocalCacheN

Asp开发的可以用来做采集与分析html代码的类

  本文发布的是用Asp开发的可以用来做采集与分析html代码的类,大家有兴趣可以参考,可以在此基础上能做出好多东东呢!
  
  <%
  
  Dim mySpider,MyConn,IsConnection
  
  IsConnection=False
  
  Set mySpider=New ClsProcess
  
  Class ClsProcess
  
  Private CacheName,Reloadtime,LocalCacheName,Cache_Data
  
  Private MaxFileSize,sAllowExtName
  
  Public PathFileName,blnPassedTest
  
  Public PictureExist
  
  '--下载大小限制
  
  Public Property Let MaxSize(ByVal NewValue)
  
  MaxFileSize=NewValue*1024
  
  End Property
  
  '--下载类型限制
  
  Public Property Let AllowExt(ByVal NewValue)
  
  sAllowExtName=NewValue
  
  End Property
  
  Public Property Get PictureEx()
  
  PictureEx=PictureExist
  
  End Property
  
  Public Property Get AllFileName()
  
  AllFileName=PathFileName
  
  End Property
  
  Private Sub Class_Initialize()
  
  On Error Resume Next
  
  Reloadtime=28800
  
  CacheName="mySpider"
  
  blnPassedTest=False
  
  PictureExist=False
  
  MaxFileSize=0
  
  sAllowExtName="gif|jpg|jpge|png|bmp|swf|fla|psd"
  
  End Sub
  
  Private Sub Class_Terminate()
  
  '--Class_Terminate
  
  End Sub
  
  '===================服务器缓存部分函数开始===================
  
  Public Property Let Name(ByVal vNewValue)
  
  LocalCacheName=LCase(vNewValue)
  
  Cache_Data=Application(CacheName&"_"&LocalCacheName)
  
  End Property
  
  Public Property Let Value(ByVal vNewValue)
  
  If LocalCacheName<>"" Then
  
  ReDim Cache_Data(2)
  
  Cache_Data(0)=vNewValue
  
  Cache_Data(1)=Now()
  
  Application.Lock
  
  Application(CacheName&"_"&LocalCacheName)=Cache_Data
  
  Application.UnLock
  
  Else
  
  Err.Raise vbObjectError+1,"NewaspCacheServer"," please change the CacheName."
  
  End If
  
  End Property
  
  Public Property Get Value()
  
  If LocalCacheName<>"" Then
  
  If IsArray(Cache_Data)Then
  
  Value=Cache_Data(0)
  
  Else
  
  'Err.Raise vbObjectError+1,"NewaspCacheServer"," The Cache_Data("&LocalCacheName&")Is Empty."
  
  End If
  
  Else
  
  Err.Raise vbObjectError+1,"NewaspCacheServer"," please change the CacheName."
  
  End If
  
  End Property
  
  Public Function ObjIsEmpty()
  
  ObjIsEmpty=True
  
  If Not IsArray(Cache_Data)Then Exit Function
  
  If Not IsDate(Cache_Data(1))Then Exit Function
  
  If DateDiff("s",CDate(Cache_Data(1)),Now())<(60*Reloadtime)Then ObjIsEmpty=False
  
  End Function
  
  Public Sub DelCahe(MyCaheName)
  
  Application.Lock
  
  Application.Contents.Remove(CacheName&"_"&MyCaheName)
  
  Application.UnLock
  
  End Sub
  
  '===================服务器缓存部分函数结束===================
  
  Public Function ChkBoolean(ByVal Values)
  
  If TypeName(Values)="Boolean" Or IsNumeric(Values)Or LCase(Values)="false" Or LCase(Values)="true" Then
  
  ChkBoolean=CBool(Values)
  
  Else
  
  ChkBoolean=False
  
  End If
  
  End Function
  
  Public Function CheckNumeric(ByVal CHECK_ID)
  
  If CHECK_ID<>"" And IsNumeric(CHECK_ID)Then_
  
  CHECK_ID=CCur(CHECK_ID)_
  
  Else_
  
  CHECK_ID=0
  
  CheckNumeric=CHECK_ID
  
  End Function
  
  Public Function ChkNumeric(ByVal CHECK_ID)
  
  If CHECK_ID<>"" And IsNumeric(CHECK_ID)Then
  
  CHECK_ID=CLng(CHECK_ID)
  
  Else
  
  CHECK_ID=0
  
  End If
  
  ChkNumeric=CHECK_ID
  
  End Function
  
  Public Function CheckNull(ByVal str)
  
  If Not IsNull(str)And Trim(str)<>"" Then
  
  CheckNull=True
  
  Else
  
  CheckNull=False
  
  End If
  
  End Function
  
  Public Function CheckStr(ByVal str)
  
  If IsNull(str)Then
  
  CheckStr=""
  
  Exit Function
  
  End If
  
  str=Replace(str,Chr(0),"")
  
  CheckStr=Replace(str,"'","''")
  
  End Function
  
  Public Function CheckNostr(ByVal str)
  
  str=Trim(str)
  
  If Len(str)=0Then
  
  CheckNostr=""
  
  Exit Function
  
  End If
  
  str=Replace(str,Chr(0),vbNullString)
  
  str=Replace(str,Chr(9),vbNullString)
  
  str=Replace(str,Chr(10),vbNullString)
  
  str=Replace(str,Chr(13),vbNullString)
  
  str=Replace(str,Chr(34),vbNullString)
  
  str=Replace(str,Chr(39),vbNullString)
  
  str=Replace(str,Chr(255),vbNullString)
  
  str=Replace(str,"%","%")
  
  CheckNostr=Trim(str)
  
  End Function
  
  Public Function CheckNullStr(ByVal str)
  
  If Not IsNull(str)And Trim(str)<>"" And LCase(str)<>"http://" Then
  
  CheckNullStr=Trim(Replace(Replace(Replace(Replace(str,vbNewLine,""),Chr(9),""),Chr(39),""),Chr(34),""))
  
  Else
  
  CheckNullStr=""
  
  End If
  
  End Function
  
  Public Function CheckMapPath(ByVal strPath)
  
  On Error Resume Next
  
  Dim fullPath
  
  strPath=Replace(Replace(Trim(strPath),"//","/"),"\\","\")
  
  If strPath="" Then strPath="."
  
  If InStr(strPath,":")=0Then
  
  strPath=Replace(Trim(strPath),"\","/")
  
  fullPath=Server.MapPath(strPath)
  
  Else
  
  strPath=Replace(Trim(strPath),"/","\")
  
  fullPath=Trim(strPath)
  
  End If
  
  If Right(fullPath,1)<>"\" Then fullPath=fullPath&"\"
  
  CheckMapPath=fullPath
  
  End Function
  
  Public Function ChkMapPath(ByVal strPath)
  
  On Error Resume Next
  
  Dim fullPath
  
  strPath=Replace(Replace(Trim(strPath),"//","/"),"\\","\")
  
  If strPath="" Then strPath="."
  
  If InStr(strPath,":")=0Then
  
  strPath=Replace(Trim(strPath),"\","/")
  
  fullPath=Server.MapPath(strPath)
  
  Else
  
  strPath=Replace(Trim(strPath),"/","\")
  
  fullPath=Trim(strPath)
  
  End If
  
  If Right(fullPath,1)<>"\" Then fullPath=fullPath&"\"
  
  fullPath=Left(fullPath,Len(fullPath)-1)
  
  ChkMapPath=fullPath
  
  End Function

分享到:
本文"Asp开发的可以用来做采集与分析html代码的类"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4