一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp小偷程序源代码

时间:2008-08-10 编辑:简简单单 来源:一聚教程网


Class Cls_Ajax
 Private oAjax, oAjax_Rs
 Private oAjax_Beta, oAjax_Method, oAjax_Url, oAjax_Char, oAjax_Err
 
 Private Sub Class_Initialize
  oAjax_Beta  = "MSXML2.XMLHTTP"
  oAjax_Method = "get"
  oAjax_Char  = 1
  oAjax_Err  = ""
 End Sub
 ' 取得Ajax对象版本
 '============================================================================
 Public Property Let isBeta(ByVal Beta)
  If Beta <> "" Then oAjax_Beta = Beta
 End Property
 
 ' 取得提交模式
 '============================================================================
 Public Property Let isMethod(ByVal Method)
  Method = Lcase(Method)
  If Method = "get" or Method = "post" Then oAjax_Method = Method
 End Property
 
 ' 取得要抓取的Url
 '============================================================================
 Public Property Let isUrl(ByVal Url)
  oAjax_Url = Url
 End Property
 
 ' 取得Char
 '============================================================================
 Public Property Let isChar(ByVal Char)
  If ToInt(Char) <> -1 Then oAjax_Char = Char
 End Property
 
 ' 返回抓到的代码
 '============================================================================
 Public Property Get GetCode()
  On Error Resume Next
  Set oAjax = Server.CreateObject(oAjax_Beta)
  If Err.Number <> 0 Then oAjax_Err = "Ajax对象创建失败!"
  oAjax.Open oAjax_Method, oAjax_Url, false
  oAjax.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
  oAjax.Send()
  
  If oAjax.readyState = 4 Then
   If oAjax_Char = 0 Then
    GetCode = oAjax.responseText
   Else
    GetCode = ToGB2312(oAjax.responseBody)
   End If
  Else
   oAjax_Err = 1
  End If
 End Property
 
 ' 返回错误信息,没做好,错误处理比较麻烦
 '============================================================================
 Public Property Get GetErr()
  GetErr = oAjax_Err
 End Property
 
 ' 编码转换
 '============================================================================
 Private Function ToGB2312(ByVal strHtml)
  Set oAjax_Rs = Server.CreateObject("ADODB.RecordSet")
  oAjax_Rs.Fields.Append "WellFrog",201,1
  oAjax_Rs.Open()
  oAjax_Rs.AddNew()
  oAjax_Rs(0).AppendChunk(strHtml)
  oAjax_Rs.Update()
  ToGB2312 = oAjax_Rs(0).Value
  oAjax_Rs.Close()
  Set oAjax_Rs = Nothing
 End function
 
 ' 专用于对isChar的验证
 Private Function ToInt(ByVal TestNum)
  If IsNumeric(TestNum) Then
   ToInt = TestNum
  Else
   ToInt = -1
  End If
 End Function
 Private Sub Class_Terminate()
  Set oAjax = Nothing
 End Sub
End Class
%>

热门栏目