經(jīng)典ASP支持使用GET方式訪問https鏈接嗎?
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
![]() ![]() 可以的,通過創(chuàng)建MSXML2.XMLHTTP對象實現(xiàn),但被訪問的網(wǎng)站可能要做兼容處理,如兼容更多的加密算法套件和舊版協(xié)議。 訪問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 ' 處理響應內(nèi)容編碼 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 編輯過 |
關鍵字查詢
相關文章
正在查詢... |