久久天天躁狠狠躁夜夜免费观看,精品国产粉嫩内射白浆内射双马尾,久久国产欧美日韩精品,久久久久久性高,激情欧美成人久久综合

IP定位,騰訊定位周邊數(shù)據(jù)分享

JSON 2018-11-20 15:18:26 58677

這些天有空,把IP查詢IP模糊定位的工具更新了一遍,開始用高德,寫完后發(fā)現(xiàn)查詢幾次要“阿里式滑動”驗證,故放棄了。

針對http://suancuo.cn/ip/ 工具,我真心怕你們“程序員”去爬蟲輸出結果,請看到這些分享,自己實現(xiàn),有難點可以咨詢我,不要采用爬蟲的方式去實現(xiàn),因為本站工具頗多,基本上好多工具都被程序員爬蟲或者模擬正常使用者大量不正常使用,而且好多“素質低”完全不管本站死活,造成本站間接性很卡。在此懇求就算用爬蟲去爬取別人的東西來實現(xiàn)某一個業(yè)務點,那也請節(jié)制一點,做好優(yōu)化,如緩存等等,還是那句話,不要把免費的資源不當資源。

騰訊IP定位申請

在騰訊地圖開放平臺“https://lbs.qq.com/”用你的QQ號或者微信號登陸,填寫個人信息,手機號及郵箱認證,就有幾萬的額度,有企業(yè)資質審核通過就會有幾十萬的免費額度。

創(chuàng)建一個KEY:https://lbs.qq.com/console/mykey.html?console=mykey

配額查看管理:https://lbs.qq.com/console/myquota.html?console=myquota

點擊提升配額需要填寫企業(yè)信息,有30萬的免費額度,一般的都夠用了,填寫完畢后會3個工作日審核


騰訊IP定位Java代碼實現(xiàn)

Http.Response response = Http.create("http://apis.map.qq.com/ws/location/v1/ip?key=你的key&ip=%s", ip)
                .get()
                .timeout(2)
                .send().getResponse();
if(response!=null && response.getStatus() == 200){
    String result = response.getResult();
    JSONObject json = JSONObject.fromObject(result);

    //判斷是否無法精準定位
    if(json.getInt("status") == 0 ){//可以定位
        JSONObject location = json.getJSONObject("result").getJSONObject("location");
        //不是默認定位值
        String lng = location.getString("lng");
        String lat = location.getString("lat");
        //騰訊定位要是定位不到,就是默認北京的這個"116.407526"和"39.90403"
        if(!("116.407526".equals(lng) && "39.90403".equals(lat))){
            try {
                //開始精準定位
                Http.Response jresponse = Http.create("https://apis.map.qq.com/ws/geocoder/v1/?location=%s,%s&get_poi=1&key=你的key",  lat,lng)
                        .head("Host","map.qq.com")
                        .head("Accept","*/*")
                        .head("Accept-Encoding","gzip, deflate, br")
                        .head("Accept-Language","zh-CN,zh;q=0.9,en;q=0.8")
                        .head("Cache-Control","no-cache")
                        .head("Referer","https://map.qq.com/")
                        .head("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36")
                        .head("X-Requested-With","XMLHttpRequest")
                        .get()
                        .timeout(2)
                        .send().getResponse();
                if(jresponse!=null && jresponse.getStatus() == 200 && StringUtils.isNotBlank(jresponse.getResult())){
                    JSONObject jjson = JSONObject.fromObject(jresponse.getResult());
                    //成功
                    if(Constant.S_ZERO.equals(jjson.optString("status"))){

                        JSONObject resultJSON = jjson.optJSONObject("result");

                        if(null != resultJSON && resultJSON.size() > 0){
                            bo.setAddress(resultJSON.optString("address"));
                            JSONObject ad_info = resultJSON.optJSONObject("ad_info");
                            bo.setDistrictadcode(ad_info.optString("adcode"));
                            JSONArray poiList = resultJSON.optJSONArray("pois");
                            //轉換
                            if(null != poiList && poiList.size() > 0){
                                List<IPBo.PoiList> poiLists = new ArrayList<>();
                                poiList.forEach(e-> poiLists.add(new IPBo.PoiList(e)));
                                bo.setPoiLists(poiLists);
                            }

                            //地區(qū)詳細詳細
                            JSONObject address_component = resultJSON.optJSONObject("address_component");

//                                                "nation":"中國",
//                                                "province":"湖南省",
//                                                "city":"長沙市",
//                                                "district":"岳麓區(qū)",
//                                                "street":"岳麓大道",
//                                                "street_number":"岳麓大道218號"
                            bo.setNation(address_component.optString("nation"));
                            bo.setProvince(address_component.optString("province"));
                            //市
                            bo.setCity(address_component.optString("city"));
                            //區(qū),可能為空字串
                            bo.setDistrict(address_component.optString("district"));
                            //街道
                            bo.setStreet(address_component.optString("street"));
                            //門牌,可能為空字串
                            bo.setStreetNumber(address_component.optString("street_number"));

                        }
                    }
                }
                //開啟精準定位
                bo.setLocation(Boolean.TRUE);
            } catch (Exception e) {
                log.error("IP 查詢精準定位請求異常,ip:%s,url:%s",ip,urlOrIp,e);
                cache = false;
            }


        }
    }

}



//數(shù)據(jù)不全,雖然成功但是不緩存
if(cache){
    //存儲半個小時
    VCache.setex(historyKey,bo,1800);
}

對應的業(yè)務BO實體


@Data
public class IPBo implements Serializable {

	private static final long serialVersionUID = -1052580448111049751L;
	
	private String ip ;//ip
	
	private String address;//地址
	private String localAddress;//本地獲取的地址
	private String baiduAddress;//百度獲取的地址

	private String ua;//瀏覽器信息
	
	private String lg;//語言
	
	private String window;//系統(tǒng)
	private String browser;//什么瀏覽器
	private int type;//300:請輸入正確的Ip或域名,500:系統(tǒng)繁忙錯誤


    //國家
    private String nation;
    //省
    private String province;
    //市
    private String city;
    //區(qū)
    private String district;
    //郵編
    private String adcode;
    //區(qū)號
    private String areacode;
    //精準區(qū)號
    private String districtadcode;
    //街道
    private String street;
    //門牌,可能為空字串
    private String streetNumber;

    private String message;

    //定位建筑 集合
    private List<PoiList> poiLists;

    //是否精準定位
    private Boolean location = Boolean.FALSE;

    public IPBo(String ip,int type,String message) {
        this.type = type;
        this.message = message;
        this.ip = ip;
    }




	public IPBo() {
	}



    @Data
    public static class PoiList implements Serializable {
        private static final long serialVersionUID = -1052180448111049751L;

        //電話
        private String tel;
        //"岳麓區(qū)政協(xié)委員會",
        private String title;
        //"望岳街道金星北路一段517號",
        private String address;
        //地址的類型 政府機構及社會團體;政府機關;區(qū)縣級政府及事業(yè)單位",
        private String category;
        //坐標
        private String lt;
        //距離
        private String distance;


        public PoiList(){

        }

        public PoiList(Object e){
                JSONObject elem;
                if(null != e && e instanceof JSONObject){
                    elem = (JSONObject) e;
                }else{
                    elem = JSONObject.fromObject(e);
                }
                this.tel = elem.optString("tel");
                this.title = elem.optString("title");
                this.address = elem.optString("address");
                this.category = elem.optString("category");
                if(StringUtils.contains(this.category,":")){
                    this.category = this.category.replaceAll(":","/");
                }
                this.distance = elem.optString("_distance");
                JSONObject location = elem.optJSONObject("location");
                if(null != location){
                    this.lt = String.format("%s/%s",location.optString("lat"),location.optString("lng"));
                }

        }

    }
	
	
	
}

JSON使用包為net.sf.json.JSONObject,地址為:http://suancuo.cn/blog/20.html


分享高德2個有用的地址:

https://www.amap.com/service/regeo?longitude=112.90131&latitude=28.20051

https://www.amap.com/service/getHistory?type=301


版權所屬:SO JSON在線解析

原文地址:http://suancuo.cn/blog/308.html

轉載時必須以鏈接形式注明原始出處及本聲明。

本文主題:

如果本文對你有幫助,那么請你贊助我,讓我更有激情的寫下去,幫助更多的人。

關于作者
一個低調而悶騷的男人。
相關文章
IP地址查詢,IP定位IP純真數(shù)據(jù)查詢
阿里云和騰訊云哪個好?
騰訊云代金券 10000 元/ 30000 代金券領取技巧
關于微信weixin.com,價值3000萬域名騰訊仲裁“0元”得手實際分析
SOJSON首頁的圣誕雪花特效,特效分享,雪花特效下載
神速ICP備案經驗分享,ICP備案居然一天就通過了
Oracle與Mysql刪除重復的數(shù)據(jù),Oracle和Mysql數(shù)據(jù)去重復
CDN + 數(shù)據(jù)中心粗粒度構想
oracle數(shù)據(jù)庫和sql server的區(qū)別
Jackson 美化輸出JSON,優(yōu)雅的輸出JSON數(shù)據(jù),格式化輸出JSON數(shù)據(jù)... ...
最新文章
計算機網絡的相關內容 354
SOJSON V6 JavaScript 解密技巧與分析 5940
微信客服人工電話95068:如何快速解封微信賬號(2025最新指南) 11866
Java Http請求,HttpURLConnection HTTP請求丟失頭信息,Head信息丟失解決方案 5052
實用API合集分享:教你輕松獲取IP地址的API合集 8839
Linux I/O重定向 6705
Ruby 循環(huán) - while、for、until、break、redo 和 retry 3990
Node.js:全局對象 3604
如何使用終端檢查Linux上的內存使用情況 3779
JavaScript對象詳細剖析 3252
最熱文章
免費天氣API,天氣JSON API,不限次數(shù)獲取十五天的天氣預報 745364
最新MyEclipse8.5注冊碼,有效期到2020年 (已經更新) 703112
蘋果電腦Mac怎么恢復出廠系統(tǒng)?蘋果系統(tǒng)怎么重裝系統(tǒng)? 678428
Jackson 時間格式化,時間注解 @JsonFormat 用法、時差問題說明 561958
我為什么要選擇RabbitMQ ,RabbitMQ簡介,各種MQ選型對比 511823
Elasticsearch教程(四) elasticsearch head 插件安裝和使用 483716
Jackson 美化輸出JSON,優(yōu)雅的輸出JSON數(shù)據(jù),格式化輸出JSON數(shù)據(jù)... ... 299543
Java 信任所有SSL證書,HTTPS請求拋錯,忽略證書請求完美解決 246654
Elasticsearch教程(一),全程直播(小白級別) 232088
談談斐訊路由器劫持,你用斐訊路由器,你需要知道的事情 227528
支付掃碼

所有贊助/開支都講公開明細,用于網站維護:贊助名單查看

查看我的收藏

正在加載... ...