首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >访问安全URL时出现msxml3错误80090326

访问安全URL时出现msxml3错误80090326
EN

Stack Overflow用户
提问于 2015-03-29 16:37:50
回答 1查看 905关注 0票数 1

我创建了以下代码:

代码语言:javascript
复制
  URL = "https://github.com/index.html"
  Set xHttp = CreateObject("MSXML2.ServerXMLHTTP")
  xHttp.Open "GET", URL, False
  xHttp.setOption 2, 13056
  xHttp.Send()

执行'xHttp.Send‘时,我得到一个msxml3错误0x80090326,“收到的消息是意外的或格式错误”。

对于其他安全URL,上述代码可以正常工作。不是为了这个!但是,开放源码实用程序'wget‘可以使用'--no-check-certificate’开关访问此URL。此外,web浏览器也可以访问此URL。VBScript需要什么才能成功?

EN

回答 1

Stack Overflow用户

发布于 2015-03-29 21:11:42

尝试以下代码:

代码语言:javascript
复制
Option Explicit
Dim URL,Save2File
URL = "https://github.com/index.html"
Save2File = "index_github.txt"
Call GetData(URL,Save2File)
 '**********************************************************************************************
 Sub GetData(URL,Save2File)
Dim File,BS,ws
On Error Resume Next
 Set File = CreateObject("MSXML2.ServerXMLHTTP")
 File.Open "GET",URL, False
 'This is IE 8 headers
 File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
 File.Send
 If err.number <> 0 then 
    line =""
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error getting file" 
    Line  = Line &  vbcrlf & "==================" 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description 
    Line  = Line &  vbcrlf & "Source " & err.source 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "HTTP Error " & File.Status & " " & File.StatusText
    Line  = Line &  vbcrlf &  File.getAllResponseHeaders
    wscript.echo Line
    Err.clear
    wscript.quit
 End If

 Set BS = CreateObject("ADODB.Stream")
 Set ws = CreateObject("wscript.Shell")
 BS.type = 1
 BS.open
 BS.Write File.ResponseBody
 BS.SaveToFile Save2File, 2
 End Sub
'**********************************************************************************************
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29327165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档