修改获取ipquery查询结果规则

This commit is contained in:
2024-11-06 09:37:54 +08:00
parent b11db84072
commit a568c3faa5
2 changed files with 4 additions and 6 deletions

Binary file not shown.

View File

@@ -33,6 +33,8 @@ func main() {
log.Fatalf("无效的 IP 地址: %s", ip)
}
//https://qifu.baidu.com/ip/geo/v1/district?ip=146.190.59.217
// 目标 URL
url := "https://qifu.baidu.com/ip/geo/v1/district?ip=" + ip
@@ -63,10 +65,6 @@ func main() {
log.Fatalf("解析 JSON 时出错: %v", err)
}
if ipInfo.Msg == "查询成功" {
// 提取并打印 continent 和 country 字段
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
} else {
fmt.Printf("查询失败\n")
}
fmt.Printf("%s%s\n", ipInfo.Data.Continent, ipInfo.Data.Country)
}