VB中Get网页源码和DownLoad函数

VB6 | 2018-08-30 20:52:49 | 阅读 166 次 | 评论(0)

调用网页源代码使用:


Dim str As String
Set xmlHTTP1 = CreateObject("Microsoft.XMLHTTP")
xmlHTTP1.open "get", "https://v1.hitokoto.cn/", True
xmlHTTP1.send
While xmlHTTP1.readyState <> 4
DoEvents
Wend
chuli (xmlHTTP1.responseText)
text = s
Set xmlHTTP1 = Nothing
Donwload可以使用系统API:



Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
调用方法为:


Call URLDownloadToFile(0, "网页地址", "保存到本地文件名和地址", 0, 0)

使用以上两个函数可以构建一个简易的文件采集程序。




文章评论,共0条
游客请输入验证码
浏览324次
最新评论