I would like to geolocate a few hundred IP addresses (as part of analysing server logs). What is the best way to do this using Mathematica?
Does Mathematica have any builtin functionality for this?
Is the best approach to try to query an online service instead? Is there one which is easy to use from Mathematica and would be able to handle up to 1000 addresses?
Should I try to find a database and use it offline from Mathematica?
I am not necessarily looking for working code. A general high-level guide on the best approach will be sufficient.
Update: For this application, performance is important. Here's a dataset to use as benchmark:
websites =
WolframAlpha[
"top websites", {{"OrdinalRankings", 1}, "ComputableData"},
PodStates -> {"OrdinalRankings__More", "OrdinalRankings__More",
"OrdinalRankings__More", "OrdinalRankings__More",
"OrdinalRankings__More"}];
Length[websites]
(* 160 *)
iplist = First /@
Flatten@DeleteMissing[HostLookup /@ websites[[All, 2]]];
Length[iplist]
(* 355 *)
URLExecute["freegeoip.net/json/someIP"]
. They allow 15000 api calls per hour, although using the above takes approx 0.7s on my computer/connection per call. Maybe you can useURLSaveAsynchronous
as in this answer $\endgroup$FindGeoLocation
. It's very slow though. $\endgroup$