最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用ASP建立Http组件
时间:2022-06-30 09:33:36 编辑:袖梨 来源:一聚教程网
生成HTTP组件
自己动手,丰衣足食,下面介绍如何生成自己的AspHttp组件。
使用Winsock控件,下面将介绍怎么来建立一个简单的HTTP组件。
记住先选择mswinsck.ocx控件
下面的代码是在VB6中编译的。
代码如下:
Private WithEvents objWinSock As MSWinsockLib.Winsock
Private strURL As String
Private strURI As String
Private strServer As String
Private nPort As Long
Private strHead As String
Private strData As String
Private bConnected As Boolean
Public Function httpGet(URL As String) As String
Set objWinSock = New MSWinsockLib.Winsock
strURL = URL
ParseURL
Connect
SendRequest
objWinSock.Close
strHead = Left(strData, InStr(strData, vbCrLf & vbCrLf))
strData = Right(strData, Len(strData) - InStr(strData, vbCrLf & vbCrLf))
httpGet = strData
End Function
Private Sub ParseURL()
If LCase(Left(strURL, 7)) = "http://" Then
If InStr(8, strURL, "/") = 0 Then
strServer = Right(strURL, Len(strURL) - 7)
strURI = "/"
Else
strServer = Mid(strURL, 8, InStr(8, strURL, "/") - 8)
strURI = Right(strURL, Len(strURL) - InStr(8, strURL, "/") + 1)
End If
If InStr(strServer, ":") <> 0 Then
自己动手,丰衣足食,下面介绍如何生成自己的AspHttp组件。
使用Winsock控件,下面将介绍怎么来建立一个简单的HTTP组件。
记住先选择mswinsck.ocx控件
下面的代码是在VB6中编译的。
代码如下:
Private WithEvents objWinSock As MSWinsockLib.Winsock
Private strURL As String
Private strURI As String
Private strServer As String
Private nPort As Long
Private strHead As String
Private strData As String
Private bConnected As Boolean
Public Function httpGet(URL As String) As String
Set objWinSock = New MSWinsockLib.Winsock
strURL = URL
ParseURL
Connect
SendRequest
objWinSock.Close
strHead = Left(strData, InStr(strData, vbCrLf & vbCrLf))
strData = Right(strData, Len(strData) - InStr(strData, vbCrLf & vbCrLf))
httpGet = strData
End Function
Private Sub ParseURL()
If LCase(Left(strURL, 7)) = "http://" Then
If InStr(8, strURL, "/") = 0 Then
strServer = Right(strURL, Len(strURL) - 7)
strURI = "/"
Else
strServer = Mid(strURL, 8, InStr(8, strURL, "/") - 8)
strURI = Right(strURL, Len(strURL) - InStr(8, strURL, "/") + 1)
End If
If InStr(strServer, ":") <> 0 Then
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21