Autox.js 实现获取IP信息,包括归属地,运营商等信息
// // 示例用法
// var ipAddress = '123.456.789.0'; // 替换为您要查询的IP地址
// var ipInfo = http访问json(`https://www.ipip.net/ip/${ipAddress}.html`);
// log(ipInfo)
// console.log('IP Information:', ipInfo);
// console.log('Location:', ipInfo.location);
// console.log('ISP:', ipInfo.isp);
// 十个获取IP地址以及运营商名称
// `https://members.ip-api.com/
// `https://ipfind.co?ip=${ipAddress}&auth=YOUR_API_KEY`
// `https://ipgeolocation.abstractapi.com/v1/?api_key=YOUR_API_KEY&ip_address=${ipAddress}`
// `https://api.ipdata.co/${ipAddress}?api-key=test`
// `https://geo.ipify.org/api/v1?apiKey=YOUR_API_KEY&ipAddress=${ipAddress}`
// `https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY&ip=${ipAddress}`
// `http://api.ipstack.com/${ipAddress}?access_key=YOUR_ACCESS_KEY`
// https://api.ipify.org/?format=json
// https://api.ipify.org?format=json
// `https://members.ip-api.com/${ipAddress}`
// `https://ipinfo.io/${ipAddress}/json`
// `http://ip-api.com/json/${ipAddress}`
// `https://ipapi.co/${ipAddress}/json/`
// `http://api.db-ip.com/v2/free/${ipAddress}`
// //获取运营商 地址和信息
// var ipAddress = "180.154.6.140";
// let 地址 = "https://ipinfo.io/" + ipAddress + "/json";
// log(地址);
// var res = http.get(地址);
// var resBodyString = res.body.string();
// log("resBodyString: " + resBodyString);
// var resBody = JSON.parse(resBodyString); // 解析JSON字符串为对象
// let ipAddress = resBody.ip;
// let city = resBody.city;
// let operator = resBody.org;
// console.log('IP地址:' + ipAddress);
// console.log('城市:' + city);
// console.log('运营商:' + operator);
// 云控提交地址
// /api/index/BindCode?code=56320858&macip=mac1222&phonetype=phoneta&phonename=电信
// var ipAddress = "43.224.52.0";
let 地址 = "http://ip-api.com/json/"
console.log(地址);
var res = http.get(地址);
var resBodyString = res.body.string();
console.log("resBodyString: " + resBodyString);
var resBody = JSON.parse(resBodyString);
let ipAddress = resBody.query;
let city = resBody.regionName;
let operator = resBody.isp;
// 将运营商转换为中文
if (operator.includes("China Telecom")) {
operator = "中国电信";
} else if (operator.includes("China Mobile")) {
operator = "中国移动";
} else if (operator.includes("China Unicom")) {
operator = "中国联通";
} else {
operator = "未知运营商";
}
console.log('IP地址:' + ipAddress);
console.log('城市:' + city);
console.log('运营商:' + operator);