28,409
社区成员




Response.CharSet = "utf-8"
ip="114.80.166.240"
html=getHTML(ip)
html = unescape(Replace(html,"\","%"))
if instr(html,"上海") then
else
end if
Function getHTML(ip)
dim xhr,url
url="http://ip.taobao.com/service/getIpInfo.php?ip="&ip
set xhr=createobject("MSXML2.XMLHTTP")
xhr.open "GET",url,false
xhr.send()
If xhr.readystate<>4 then
exit function
End If
getHTML=getText(xhr.responseBody)
set xhr=nothing
if err.number<>0 then err.Clear
End Function
Function getText(body)
dim ado
set ado = CreateObject("adodb.stream")
ado.Type = 1
ado.Mode =3
ado.Open
ado.Write body
ado.Position = 0
ado.Type = 2
ado.Charset = "gb2312"
getText = ado.ReadText
ado.Close
set ado = nothing
end Function
ip="114.80.166.240"
html=getHTML(ip)
response.Write ip&":"
if instr(html,"""city"":""\u4e0a\u6d77\u5e02""")<>0 then
response.Write "上海市ip"
else
response.Write "不是上海市ip"
end if
response.Write "<br>"
ip="121.52.209.112"
html=getHTML(ip)
response.Write ip&":"
if instr(html,"""city"":""\u4e0a\u6d77\u5e02""")<>0 then
response.Write "上海市ip"
else
response.Write "不是上海市ip"
end if