Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
检索有关 IPv4 或 IPv6 地址的地理位置信息。
语法
geo_info_from_ip_address(
IpAddress)
详细了解语法约定。
参数
| 客户 | 类型 | 必需 | 说明 |
|---|---|---|---|
| IpAddress | string |
✔️ | 用于检索地理位置信息的 IPv4 或 IPv6 地址。 |
返回
包含有关 IP 地址下落信息的动态对象(如果信息可用)。 该对象包含以下字段:
| 客户 | 类型 | 说明 |
|---|---|---|
country |
string |
国家/地区名称 |
state |
string |
国家(细分)名称 |
city |
string |
城市名称 |
latitude |
real |
纬度坐标 |
longitude |
real |
经度坐标 |
注意
- IP 地理位置本身并不精确;位置通常靠近人口密集地。 此函数提供的任何位置都不应用于标识特定地址或家庭住址。
- 此函数使用 maxMind 创建的免费
GeoLite2-City数据,可从 https://www.maxmind.com获取。 请注意,MaxMind 网站上的演示版本利用其商业服务,这可能提供比geo_info_from_ip_address()函数支持的更高质量的结果。 - 此函数还基于 ISC 许可提供的 MaxMind DB 读取器库。
注意
要进一步操作生成的数组,请参阅动态对象访问器。
示例
以下示例检索有关指定 IPv4 地址的地理位置信息。
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} |
以下示例检索有关指定 IPv6 地址的地理位置信息。
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} |