• Get something from a website
    2 replies, posted
Hi, I wondered if someone knew about how could I get something from a page. Example : [url]http://www.telize.com/geoip/[/url] I want to get this : "city":"cityname" Any ideas ??
Here's what I use in my code. [lua] hook.Add("PlayerAuthed", "ADMIN_PlayerAuthed", function( ply ) local IPAddress = string.Explode(":", ply:IPAddress()) IPAddress = IPAddress[1] http.Fetch("http://ipinfo.io/" .. IPAddress .. "/json", function( str ) local tbl, str = util.JSONToTable(str), "" if tbl['region'] != nil and tbl['region'] != "" then str = str .. tbl['region'] .. ", " end if tbl['country'] != nil and tbl['country'] != "" then str = str .. tbl['country'] end if str == "" then ADMIN:NotifyAll(Color(20, 200, 20), ply:Nick(), color_white, " has connected from ", Color(200, 20, 20), "Hell", color_white, ".") else ADMIN:NotifyAll(Color(20, 200, 20), ply:Nick(), color_white, " has connected from ", Color(20, 200, 20), str, color_white, ".") end end, function() ADMIN:NotifyAll(Color(20, 200, 20), ply:Nick(), color_white, " has connected.") end) end) [/lua]
Thanks bro !
Sorry, you need to Log In to post a reply to this thread.