作者在 2018-08-30 20:52:49 发布以下内容
调用网页源代码使用:
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)
使用以上两个函数可以构建一个简易的文件采集程序。