在需要统计设备大致ip地址和区域的场景下,通过网络请求接口来获取是最方便的一种方式
以下两个接口是通过最便捷的.
1.pconline
https://whois.pconline.com.cn/ipJson.jsp?json=true&ip=203.119.241.39
返回内容如下,如果不传ip则返回本机地址信息
{"ip":"203.119.241.39","pro":"河北省","proCode":"130000","city":"张家口市","cityCode":"130700","region":"","regionCode":"0","addr":"河北省张家口市 阿里巴巴","regionNames":"","err":""}
2.bilibili
https://api.live.bilibili.com/client/v1/Ip/getInfoNew
返回信息如下
{"code":0,"msg":"","message":"","data":{"addr":"123.123.237.169","country":"中国","province":"北京","city":"北京","isp":"联通","latitude":"39.938884","longitude":"116.397459"}}