从远程脚本获取用户IP

Get user IP from remote script

我有一个从远程位置加载脚本的页面(比如 myscript.com

此脚本向远程 API 发出 Ajax 请求。

这个API如何获取访问者的IP地址?

如果我在请求处理程序中使用 request.remote_addr,我会从脚本的位置 (myscript.com) 获取 IP。

使用此 api 获取所有这些数据作为 json 访问过您的页面
{"as":"AS9583SifyLimited","city":"Bengaluru","country":"India","countryCode":"IN","isp":"Sify Limited","lat":12.9833,"lon":77.5833,"org":"Sify Limited","query":"202.191.210.194","region":"KA","regionName":"Karnataka","status":"success","timezone":"Asia/Kolkata","zip":"560099"}

 API_Location=' http://ip-api.com/json';
            $.getJSON( API_Location)
              .done(function( position ) {
                  if (position.lat && position.lon) {
                    updateWeather(position);
                } else {
                    updateWeather({"lat":DEFAULT_LAT, "lon":DEFAULT_LON});
                }
              })
              .fail(function( jqxhr, textStatus, error ) {
                var err = textStatus + ", " + error;
                console.log( "Request Failed: " + err );
            });

访问此页面ip,您可以了解如何获取 ip!