GeoIP

Geographical IP look up to find where an IP address is located.

The fast way using GeoIP software:

# sudo apt-get install geoip-bin
(de ip2country (Ip)
   (in (list "geoiplookup" Ip)
      (use (@A @B @C)
         (match '(@A ":" " " @B "," " " @C) (line))
         (mapcar pack (list @B @C)))))
...
: (ip2country "89.16.183.67")
-> ("GB" "United Kingdom")

Or the slow way using Gumby web service:

(load "@lib/http.l" "@lib/xml.l")
...
(de ip2country (Ip)
   (client "gumby.appspot.com" 80 (pack "/api/?format=xml&ip=" Ip)
      (from "^M^J^M^J")
      (when (xml?)
         (nth (xml) 5 4 3 1))))
...
: (ip2country "89.16.183.67")
-> "GB"


This page is linked from: picoLisp

Revisions: View source XHTMLV | RSSV

picoWiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively