📄 如何自动下载http文件.txt
字号:
在 VB中 有 一 个 Internet Transfer Control控 件 可 以 用 来 下 载 HTTP和 FTP文 件 。 下 面 是 一 个 例 子 :
Private Sub Command2_Click()
MsgBox Inet1.OpenURL("http://www.nb.zj.cninfo.net/stock/stock.dbf")
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant ' Data variable.
Select Case State
' ... Other cases not shown.
Case icResponseCompleted ' 12
' Open a file to write to.
Open "c:\temp\stock.dbf" For Binary Access _
Write As #1
' Get the first chunk. NOTE: specify a Byte
' array (icByteArray) to retrieve a binary file.
vtData = Inet1.GetChunk(1024, icString)
Do While LenB(vtData) > 0
Put #1, , vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
Loop
Put #1, , vtData
Close #1
End Select
End Sub
另 外 可 以 使 用 ResponseCode 属 性 获 得 服 务 器 返 回 的 代 码 。
<END>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -