asp中如何通過(guò)ajax獲取遠(yuǎn)端服務(wù)器上指定頁(yè)面的數(shù)據(jù)
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
:asp中如何通過(guò)ajax獲取遠(yuǎn)端服務(wù)器上指定頁(yè)面的數(shù)據(jù) 下面以asp從ip138網(wǎng)站中獲取IP地址為例說(shuō)明:
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,"本站數(shù)據(jù):")>0 and instr(getAddrTmp,"</li>")>0 then getAddr=left(split(split(getAddrTmp,"本站數(shù)據(jù):")(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 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |