geo_info_from_ip_address()

检索有关 IPv4 或 IPv6 地址的地理位置信息。

语法

geo_info_from_ip_address(IpAddress)

详细了解语法约定

参数

客户 类型​​ 必需 说明
IpAddress string 用于检索地理位置信息的 IPv4 或 IPv6 地址。

返回

包含有关 IP 地址下落信息的动态对象(如果信息可用)。 该对象包含以下字段:

名称 Type 描述
country string 国家/地区名称
state string 国家(细分)名称
city string 城市名称
latitude real 纬度坐标
longitude real 经度坐标

注意

  • IP 地理位置本身并不精确;位置通常靠近人口密集地。 此函数提供的任何位置都不应用于标识特定地址或家庭住址。
  • 此函数使用 MaxMind 创建的 GeoLite2 数据(可从 https://www.maxmind.com 获取)。
  • 此函数还基于 ISC 许可提供的 MaxMind DB 读取器库。

注意

要进一步操作生成的数组,请参阅动态对象访问器

示例

print ip_location=geo_info_from_ip_address('20.53.203.50')

输出

ip_location
{"country": "Australia", "state": "New South Wales", "city": "Sydney", "latitude": -33.8715, "longitude": 151.2006}
print ip_location=geo_info_from_ip_address('2a03:2880:f12c:83:face:b00c::25de')

输出

ip_location
{"country": "United States", "state": "Florida", "city": "Boca Raton", "latitude": 26.3594, "longitude": -80.0771}