对这篇文章有类似的问题:
我正在尝试从我的内部和外部网络上运行良好的网络服务器下载文件,但是当我尝试从安全的https://服务器下载时却没有。
我收到以下错误Error picture here
我曾尝试从上面的问题中复制信息,但我没有把它弄好。你能帮忙吗?
如果不尝试访问https,它在内部和外部都很好用。
Dim strURL, strFile, strFolder, oFSO, dt, oHTTP, oStream
strURL = "https://xx.xx.xx.xx/DataLogs/xxx.csv" 'external secure site
'strURL = "http://192.168.1.10/DataLogs/PLCData.csv" 'internal test
FileName="xxx.csv"
'FileName="PLCData.csv"
strFile = "xxx.csv" ''# The file name
'strFile = "PLCData.csv" ''# The file name
strFolder = "C:\PLC Data" '# The folder where to save the files
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
''# If the download folder doesn't exist, create it
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Not oFSO.FolderExists(strFolder) Then
oFSO.CreateFolder strFolder
End If
Set dt = CreateObject("WbemScripting.SWbemDateTime")
dt.SetVarDate Now
strFile = oFSO.GetBaseName(strFile) & "-" & Split(dt.Value, ".")(0) & "." & oFSO.GetExtensionName(strFile)
''# Download the URL
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP") 'replace with? Set oHTTP = CreateObject("MSXML2.XMLHTTP") MSXML2.ServerXMLHTTP
oHTTP.open "GET", strURL, False
oHTTP.send
If oHTTP.Status <> 200 Then
''# Failed to download the file
WScript.Echo "Error " & oHTTP.Status & ": " & oHTTP.StatusText
Else
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = adTypeBinary
oStream.Open
''# Write the downloaded byte stream to the target file
oStream.Write oHTTP.ResponseBody
oStream.SaveToFile oFSO.BuildPath(strFolder, strFile), adSaveCreateOverWrite
oStream.Close
End If