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内容
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" '增加特别标识
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" '阿里云用来解析IP信息的网址
strJson = geturl_diy(url,"ali_getip","")
'以下是获得的内容
'{"data":{"ip":"44.227.127.2","long_ip":"753106690","isp":"Amazon","area":"","region_id":"","region":"","city_id":"","city":"波特兰","country_id":"US","country":"美国"},"ret":200,"msg":"success","log_id":"4e00b3aeca8f4763ab26f0fbb6eee9d7"}
'测试演示使用的
'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 '国家
guojia_id = objTest.data.country_id '国家编号
shengfen = objTest.data.region '省份
chengshi = objTest.data.city '城市
diqu = objTest.data.area '地区
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