GetIpinfo函数:调用API获取IP信息,可批量查询


AI总结

此内容由AI根据文章内容自动生成。AI By BigModel

生成摘要失败

API信息

ULR

https://api.vvhan.com/api/getIpInfo

参数

参数名 必填 类型 参数说明
ip string ip地址

返回

{"success":true,"ip":"58.154.0.0","info":{"lsp":"中国辽宁沈阳市沈阳建筑大学","country":"中国","prov":"辽宁","city":"沈阳市"}}

使用函数构建

先构建一个:🌏 GetJson函数

基于GetJson+LAMBDA构建GetIpinfo函数

GetIpinfo=LAMBDA(ip, return,
    LET(
        ipjson, WEBSERVICE(
            "https://api.vvhan.com/api/getIpInfo?ip=" &
                ip
        ),
        IF(
            OR(
                return = "",
                return = 0
            ),
            HSTACK(
                GetJsonParam(
                    ipjson,
                    "country"
                ),
                GetJsonParam(
                    ipjson,
                    "prov"
                ),
                GetJsonParam(
                    ipjson,
                    "city"
                ),
                GetJsonParam(
                    ipjson,
                    "lsp"
                )
            ),
            GetJsonParam(
                ipjson,
                return
            )
        )
    )
)

使用方法

=GetIpinfo(ip,return)

当return=0时,默认输出国家、省、市、运营商

或输出指定参数:如return=country、prov、city、lsp

讨论