从远程脚本获取用户IP

Get user IP from remote script

本文关键字:获取 用户 IP 脚本 程脚本      更新时间:2023-09-26

我有一个从远程位置加载脚本的页面(比如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!