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 编辑过 |
关键字查询
相关文章
正在查询... |