经典ASP支持使用GET方式访问https链接吗?
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
![]() ![]() 可以的,通过创建MSXML2.XMLHTTP对象实现,但被访问的网站可能要做兼容处理,如兼容更多的加密算法套件和旧版协议。 访问https的参考代码: <% Dim objHTTP, url, responseText url = "https://example.com/api/data" Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP") objHTTP.Open "GET", url, False ' 设置请求头模拟浏览器行为 objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0" objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" On Error Resume Next objHTTP.Send() If Err.Number <> 0 Then Response.Write "错误: " & Err.Description Else If objHTTP.Status = 200 Then ' 处理响应内容编码 Dim objStream Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type = 1 '二进制模式 objStream.Open objStream.Write objHTTP.responseBody objStream.Position = 0 objStream.Type = 2 '文本模式 objStream.Charset = "utf-8" responseText = objStream.ReadText objStream.Close
Response.Write "获取成功: " & Left(responseText, 500) & "..." Else Response.Write "HTTP错误: " & objHTTP.Status & " - " & objHTTP.statusText End If End If Set objHTTP = Nothing %> 该文章在 2025/9/4 16:51:09 编辑过 |
关键字查询
相关文章
正在查询... |