
Dim ip,datatype,token,url
Function BytesToBstr(strBody,CodeBase)
dim objStream
set objStream = Server.CreateObject("Adodb.Stream")
objStream.Type = 1
objStream.Mode =3
objStream.Open
objStream.Write strBody
objStream.Position = 0
objStream.Type = 2
objStream.Charset = CodeBase
BytesToBstr = objStream.ReadText
objStream.Close
set objStream = nothing
End Function
'Get內(nèi)容
Function geturl_diy(url,d_biaoqian,xml2)
dim http
set http=server.createobject("Msxml2.ServerXMLHTTP")
http.open "GET",url,false
http.setRequestHeader "If-Modified-Since","0"
http.setRequestHeader "Authorization","APPCODE b2519882bc354febb205fdd660dd4fbf" '增加特別標(biāo)識(shí)
http.send()
geturl_diy=http.responsetext
'GetURL=bytesToBSTR(http.responseBody,"gb2312")
geturl_diy=BytesToBstr(http.responseBody,"utf-8")
set http=nothing
End Function
ip_url = "https://api01.aliyun.venuscn.com/ip?ip=44.227.127.2" '阿里云用來(lái)解析IP信息的網(wǎng)址
strJson = geturl_diy(url,"ali_getip","")
'以下是獲得的內(nèi)容
'{"data":{"ip":"44.227.127.2","long_ip":"753106690","isp":"Amazon","area":"","region_id":"","region":"","city_id":"","city":"波特蘭","country_id":"US","country":"美國(guó)"},"ret":200,"msg":"success","log_id":"4e00b3aeca8f4763ab26f0fbb6eee9d7"}
'測(cè)試演示使用的
'j_txtsrc = "iptest.txt"
'strJson = ReadFromTextFile(Server.MapPath(""& j_txtsrc &""),"utf-8")
Call InitScriptControl:Set objTest = getJSONObject(strJson)
if objTest.msg="success" then
guojia = objTest.data.country '國(guó)家
guojia_id = objTest.data.country_id '國(guó)家編號(hào)
shengfen = objTest.data.region '省份
chengshi = objTest.data.city '城市
diqu = objTest.data.area '地區(qū)
yunyingshang = objTest.data.isp 'isp
end if
Response.Write objTest.msg & "___<br>"
Response.Write strJson & "___<br>"
Response.Write guojia & "___<br>"
Response.Write guojia_id & "___<br>"
Response.Write shengfen & "___<br>"
Response.Write chengshi & "___<br>"
Response.Write diqu & "___<br>"
Response.Write yunyingshang & "___<br>"
response.end
您發(fā)布的評(píng)論即表示同意遵守以下條款:
一、不得利用本站危害國(guó)家安全、泄露國(guó)家秘密,不得侵犯國(guó)家、社會(huì)、集體和公民的合法權(quán)益;
二、不得發(fā)布國(guó)家法律、法規(guī)明令禁止的內(nèi)容;互相尊重,對(duì)自己在本站的言論和行為負(fù)責(zé);
三、本站對(duì)您所發(fā)布內(nèi)容擁有處置權(quán)。