I am unable to parse json from http://api.ipregistry.co
The json output is like:
Code: Select all
{
"security": {
"is_abuser": false,
"is_attacker": false,
"is_bogon": false,
"is_cloud_provider": false,
"is_proxy": false,
"is_relay": false,
"is_tor": false,
"is_tor_exit": false,
"is_vpn": false,
"is_anonymous": false,
"is_threat": false
}
}
Code: Select all
# json parse
proc getjson {get data} {
set parse [::json::json2dict $data]
set return ""
foreach {name info} $parse {
if {[string equal -nocase $name $get]} {
set return $info
break;
}
}
return $return
}
# process check proxy
proc proxy_check {ip} {
global getjson
set link "http://api.ipregistry.co/$ip?key=s1nr112dyxmw3oy9"
set ipq [http::config -useragent "lynx"]
set ipq [::http::geturl $link]
set data [http::data $ipq]
::http::cleanup $ipq
set is_abuser [getjson "is_abuser" $data]
set is_attacker [getjson "is_attacker" $data]
set is_bogon [getjson "is_bogon" $data]
set is_cloud_provider [getjson "is_cloud_provider" $data]
set is_proxy [getjson "is_proxy" $data]
set is_relay [getjson "is_relay" $data]
set is_tor [getjson "is_tor" $data]
set is_tor_exit [getjson "is_tor_exit" $data]
set is_vpn [getjson "is_vpn" $data]
set is_anonymous [getjson "is_anonymous" $data]
set is_threat [getjson "is_threat" $data]