I've been looking around for a bit for a free location lookup based on an IP address. Preferably as an API call so I don't need to install/add too much my end.I've come across hostip.info. This service is a community-based project with around 8,542,587 entries in the database!They have a good API which supplies text and XML results, and they even have the database freely available for download with daily updates.Below is a quick example of some code to get the country (you can find more examples at the site). If you want to see it in action click here.
geoXml = xmlParse(geoInfo.fileContent); country = geoXml.HostipLookupResultSet['gml:featureMember']['hostip']['countryname'].xmlText; countryAbbrev = geoXml.HostipLookupResultSet['gml:featureMember']['hostip']['countryAbbrev'].xmlText;Your IP address is: #cgi.remote_host#For more info/help see also:\n\n
Your country is: #country# (#countryAbbrev#)