asp中如何通過ajax獲取遠端服務器上指定頁面的數據
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
:asp中如何通過ajax獲取遠端服務器上指定頁面的數據 下面以asp從ip138網站中獲取IP地址為例說明:
Function getAddr(from_IP) getAddr="未知地址" if from_IP &"CS"<>"CS" then dim objXML,getAddrTmp set objXML=createobject("MSXML2.XMLHTTP") objXML.open "post","https://www.ip138.com/iplookup.asp?action=2&ip="& from_IP,false objXML.send() If objXML.readystate<>4 then exit function End If getAddrTmp=BytesToBstr(objXML.responseBody) if instr(getAddrTmp,"本站數據:")>0 and instr(getAddrTmp,"</li>")>0 then getAddr=left(split(split(getAddrTmp,"本站數據:")(1),"</li>")(0),50) set objXML=nothing if err.number<>0 then err.Clear end if End Function Function BytesToBstr(body) dim objstream set objstream = CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = "GB2312" '編碼方式 BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing end Function temp_ip="156.2.36.96" response.write (getAddr(temp_ip)) 該文章在 2024/3/28 10:17:46 編輯過 |
關鍵字查詢
相關文章
正在查詢... |