您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
使用ASP建立Http组件
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 13:49:58
nbsp;                       Dim dtStart As Date
                         dtStart = Now()
                         strCmd = "GET " & strURI & " HTTP/1.0" & vbCrLf
                         strCmd = strCmd & "User-Agent: aspHttp.http" & vbCrLf
                         strCmd = strCmd & "Accept: */*" & vbCrLf
                         strCmd = strCmd & vbCrLf
                         objWinSock.SendData strCmd
                         Do Until objWinSock.State = sckClosing
                              DoEvents
                              If DateDiff("s", dtStart, Now) > 60 Then
                                   Err.Raise vbObjectError, "Error", "请求超时"
                              End If
                         Loop
                    End Sub

                    Public Property Get Head() As Variant
                         Head = strHead
                    End Property

                    Public Property Get Body() As Variant
                         Body = strData
                    End Property

                    Private Sub objWinSock_DataArrival(ByVal bytesTotal As Long)
                         Dim strTemp
                         objWinSock.GetData strTemp, vbString
                         strData = strData & strTemp
                    End Sub

                    Private Sub objWinSock_Connect()
                         bConnected = True
                    End Sub

                    Private Sub objWinSock_Error(ByVal Number As Integer, Description As String, _
                      ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
                      ByVal HelpContext As Long, CancelDisplay As Boolean)

                         Err.Raise vbObjectError, "Error", "Winsock Error: " & Number &
                    vbCrLf & Description
                         CancelDisplay = True
                    End Sub
编译该组件,然后按照下面的步骤注册该组件
                    C: et stop iisadmin /y
                    C:mtxstop
编译成Active Dll
                    C: et start w3svc
在ASP中调用这个组件

                    <%@ Language=VBScript %>
                    <HTML>
                    <HEAD>
                    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
                    </HEAD>
                    <BODY>
                    <%
                    Dim obj
                    Set obj = Server.CreateObject("aspHttp.http")
                    Response.Write obj.httpGet("http://www.chinaasp.com.cn")
                    %>
                    </BODY>
                    </HTML>


上一页  [1] [2] 


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |