
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
呢 稱: | |
表 情: | |
內 容: |
評論內容:不能超過 1000 字,需審核,請自覺遵守互聯網相關政策法規。 |
驗證碼: | |
您發布的評論即表示同意遵守以下條款:
一、不得利用本站危害國家安全、泄露國家秘密,不得侵犯國家、社會、集體和公民的合法權益;
二、不得發布國家法律、法規明令禁止的內容;互相尊重,對自己在本站的言論和行為負責;
三、本站對您所發布內容擁有處置權。