通过IP地址检测ISP(或/和国家/地区)

问题描述:

互联网上有很多服务我们可以找到我们机器的外部IP地址,但这些服务通常提供有关互联网提供商或国家(或两者)的信息。

There are plenty of services over the Internet where we can find out the external IP address of our machine, but also such services usually provide information about Internet provider or country (or both).

所以我的问题是:我怎样才能以编程方式获取这些信息知道IP地址?是否有一些公共目录或某些API用于检索此类信息?

So my question is: how can I obtain such information programmatically knowing the IP Address? Are there some public catalogs or some API's for retrieving such kind of information?

您可以使用我的服务, http://ipinfo.io API。以下是它提供的详细信息示例:

You can use my service, the http://ipinfo.io API. Here's an example of the details it provides:

$ curl ipinfo.io
{
  "ip": "67.188.232.131",
  "hostname": "c-67-188-232-131.hsd1.ca.comcast.net",
  "city": "Milpitas",
  "region": "California",
  "country": "US",
  "loc": "37.44040000000001,-121.87049999999999",
  "org": "AS7922 Comcast Cable Communications, Inc.",
  "postal": "95035",
  "phone": 408
}

有关详细信息,请参见 http://ipinfo.io/developers

See http://ipinfo.io/developers for more information.