日期:2014-05-17 浏览次数:20910 次
<%
    
                                //用户地理位置及其IP
                                String ipAndAddress ="";
        try{
        //获取当前IP 和地理位置信息 sdy
        URL url = new Url("http://fw.qq.com/ipaddress"); //腾讯接口 
        URLConnection   connection   =   url.openConnection(); 
        connection.connect(); 
        BufferedReader inreader = new BufferedReader( 
                                                            new InputStreamReader(connection.getInputStream(),"GB2312"));
        String str = null;
        if(inreader.ready() )
        {
            str = inreader.readLine();
        }
        String[] strArr_0 = str.split("Array");
        str = strArr_0[1].replaceAll("\"","");    
        String[] strArr_1 =str.substring(1,str.length()-2).split(","); 
        ipAndAddress = strArr_1[2]+" "+strArr_1[3];
        }catch(Exception e){
            ipAndAddress ="江苏省**市(内网)";
        }
%>