国产精品白浆熟女,国产偷亚洲偷欧美偷精品,,新免费无码国产在线看,国产激情久久久久影院老熟女

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

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

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

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

騰訊IP定位申請

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

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

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

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


騰訊IP定位Java代碼實(shí)現(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);

    //判斷是否無法精準(zhǔn)定位
    if(json.getInt("status") == 0 ){//可以定位
        JSONObject location = json.getJSONObject("result").getJSONObject("location");
        //不是默認(rèn)定位值
        String lng = location.getString("lng");
        String lat = location.getString("lat");
        //騰訊定位要是定位不到,就是默認(rèn)北京的這個(gè)"116.407526"和"39.90403"
        if(!("116.407526".equals(lng) && "39.90403".equals(lat))){
            try {
                //開始精準(zhǔn)定位
                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");
                            //轉(zhuǎn)換
                            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ū)詳細(xì)詳細(xì)
                            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"));

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


        }
    }

}



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

對應(yīng)的業(yè)務(wù)BO實(shí)體


@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)繁忙錯(cuò)誤


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

    private String message;

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

    //是否精準(zhǔn)定位
    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é)委員會(huì)",
        private String title;
        //"望岳街道金星北路一段517號",
        private String address;
        //地址的類型 政府機(jī)構(gòu)及社會(huì)團(tuán)體;政府機(jī)關(guān);區(qū)縣級政府及事業(yè)單位",
        private String category;
        //坐標(biāo)
        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://zijieyoumin.cn/blog/20.html


分享高德2個(gè)有用的地址:

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

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


版權(quán)所屬:SO JSON在線解析

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

轉(zhuǎn)載時(shí)必須以鏈接形式注明原始出處及本聲明。

本文主題:

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

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

所有贊助/開支都講公開明細(xì),用于網(wǎng)站維護(hù):贊助名單查看

查看我的收藏

正在加載... ...