代码
XML
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
JAVA
package com.fy.microservice.government.service.impl;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.fy.microservice.government.utils.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @class MapUtils
* @date 2022/6/15 10:21
*/
public class MapUtils {
static {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
List<ch.qos.logback.classic.Logger> loggerList = loggerContext.getLoggerList();
loggerList.forEach(logger -> {
logger.setLevel(Level.ERROR);
});
}
private static String[] keywordArr = {
"龙湖春江郦城14号商铺","龙井路26号","鸠坑乡青苗村村委楼","鸠坑乡星光村村委楼","鸠坑乡中联村村委楼","鸠坑乡中联村中村畈64号","风雅钱塘小区16幢1单元","陈家园村村委","闻堰街道文体中心东三楼","长河路1401号","长山社区","长山头村村委","镜洪村村委楼","钟山人民政府司法所","金峰乡锦溪村蒋岭脚村委办公楼","金峰乡金峰村塘畈自然村18号","金东方社区居委会东方郡4幢","里商乡鱼泉村委楼","里商乡里阳村1号","西湖村村委楼","衙前镇党群服务中心一楼","董家社区三里亭农贸市场南二楼董家社区","萧山区进化镇党群服务中心四楼","萧山区瓜沥镇运西村村民委员会","萧山区瓜沥镇永福村村民委员会","萧山区瓜沥镇司法所","萧山区瓜沥镇人民政府","萧山区瓜沥镇东灵社区居民委员会","萧山区瓜沥镇三岔路村村民委员会","萧山区新塘街道霞江村村委会调解室","萧山区新塘街道社会矛盾纠纷调处化解中心3楼301","萧山区新塘街道文源社区居委会调解室","萧山区新塘街道广泽社区居委会202","萧山区振宁路32号矛调中心二楼","萧山区所前镇祥里王村2楼展示室","萧山区所前镇信谊村2楼展示室","萧山区戴村镇新甸路党群服务中心","萧山区市心北路与利华路交叉路口西南侧盈丰街道矛调中心","萧山区城厢街道萧然东路353号城厢街道矛调中心内","萧山区南阳街道东风村村委会481号","萧山区北干街道风情大道12号附近金风社区居委会","萧山区北干街道金城路1269号北干街道办事处一楼108室","萧山区北干街道永金路235号绿茵苑社区居委会","萧山区北干街道新康路12号广德社区居委会","萧山区北干街道工人路617号工人路社区居委会","萧山区北干街道北干一苑路85号北干一苑社区居委会","萧山区党湾镇梅东村村委会","萧山区党湾镇人民政府2号楼2101","萧山区义桥镇人民政府106室","花城社区","芝兰村村委","石林镇富德村44号石林镇人民政府104室","石林镇双西村村委楼会议室","盛乐村村委","盛中村村委会","盛东村村委","盈中村村委","白马湖和院4-8号","界首乡姚家村130号","瑶山乡何家村40号","王阜乡王阜村村委楼","王阜乡上仙庵1号","滨江区镇前路56-58","滨江区西湘路39号","滨江区西兴街道青年路1号","滨江区西兴街道江汉东路64号附近","滨江区西兴街道新州花苑8幢副楼","滨江区艺洲街江畔云庐12号","滨江区滨盛路4400号","滨江区滨盛路4048号","滨江区滨盛路3867号","滨江区滨文路646号浙新小区32幢","滨江区滨康路96号","滨江区江汉东路158号","滨江区山秀景苑7幢","滨江区南环路4025号","滨江区冠山路浦乐新苑","滨江区亚科中心A座103室","滨江区","温馨社区居委会","浪川乡马石村村委楼","浪川乡裕丰村村委楼","浪川乡芳梧村中村1号","浪川乡联欢村方家68号","浪川乡新桥村村委楼","浪川乡峰川村村委楼","浪川乡大联村21号","沿江村村委","河上镇众联村村委","河上镇东山村村委","汾口镇郑家村村委楼","汾口镇祝家村村委楼","汾口镇百亩畈村委楼","汾口镇横沿村村委楼","汾口镇杨旗坦村委楼","汾口镇人民政府","汾口镇三渡村村委楼","江汉路1688号","江南镇江南路","江南村村委办事大厅","江南文苑小区14幢","梓桐镇人民政府(府前路8号)","桐庐县新合乡新四村外松山自然村(新合乡人民政府内)","桃源凌家村村委楼","枫树岭镇衍昌村关爱村委楼","枫树岭镇白马村关爱村委楼","枫树岭镇源塘村关爱村委楼","枫树岭镇枫林前街43号","枫树岭镇大桥头村关爱村委楼","枫树岭镇夏村村关爱村委楼","枫树岭镇夏峰村关爱村委楼","枫树岭镇丰家源村关爱村委楼","枫树岭镇下姜村村委楼","枫树岭镇上江村关爱村委楼","杭州市钱塘区白杨街道4号大街交叉路口(白杨街道办事处内)","杭州市钱塘区河庄街道永丰路618号(街道办事处内)","杭州市钱塘区新湾街道新宏路38号(平安大院内)","杭州市钱塘区前进街道梅林大道与观十五线交叉口(前进街道办事处内)","杭州市钱塘区义蓬街道义府大街668号(义蓬街道办事处内)","杭州市钱塘区临江街道纬六路1077号(临江佳苑社区)","杭州市钱塘区下沙街道海达南路555号(下沙街道办事处新综治中心)","杭州市钱塘区下沙街道幸福南路1116号和茂大厦群楼矛调中心","杭州市西湖区龙井路1号信访矛调中心","杭州市西湖区转塘街道尚德社区横桥路98号(尚德社区三楼)","杭州市西湖区西溪街道马塍路10号西溪街道党群服务中心三楼","杭州市西湖区西溪街道文天社区文三新村3-1文天社区邻里之家","杭州市西湖区西溪街道文三社区天目山路120号文三社区居委会","杭州市西湖区西溪街道上马塍社区混堂巷13号南上马塍社区居委会一楼","杭州市西湖区蒋村街道紫霞街诚园正信苑2号楼1单元","杭州市西湖区蒋村街道紫荆花路3号府苑新村17幢","杭州市西湖区蒋村街道云起路11号(蒋村街道矛盾纠纷调解中心二楼)","杭州市西湖区翠苑街道九莲社区九莲新村37幢南侧党群服务中心2楼","杭州市西湖区翠苑街道万塘路69号(翠苑街道办事处内)","杭州市西湖区留下街道西穆坞社区杨梅山路216号玉屏居5幢一楼","杭州市西湖区留下街道翰墨香林苑15幢1楼社区大厅","杭州市西湖区留下街道128号(留下街道办事处内)","杭州市西湖区灵隐街道求是村29幢","杭州市西湖区灵隐街道外东山弄70号(灵隐街道办事处内)","杭州市西湖区浙大路35号矛调中心二号楼113室","杭州市西湖区文三西路428号文新街道办事处101","杭州市西湖区古荡街道紫荆花路33号","杭州市西湖区古荡街道紫庭北弄5号","杭州市西湖区双浦镇袁浦街165-1","杭州市西湖区双浦镇板桥村村委板桥村1号","杭州市西湖区双浦镇杭江村村委杭江村486号","杭州市西湖区双浦镇吴家村村委吴家村175号","杭州市西湖区双浦镇下杨村村委下杨村401号","杭州市西湖区北山街道桃花弄8号(北山街道办事处内)","杭州市西湖区三墩镇西城年华西苑社区居委会","杭州市西湖区三墩镇绕城村村委会","杭州市西湖区三墩镇政苑小区政苑社区居委会","杭州市西湖区三墩镇三墩街188号","杭州市萧山经济技术开发区建设一路1699号","杭州市萧山区靖江街道靖东村5组22号村委会二楼","杭州市萧山区靖江街道申达路255号司法所一楼","杭州市萧山区益农镇镇龙殿村村委会","杭州市萧山区益农镇红阳路88号","益农镇政府4号楼建筑","杭州市萧山区益农镇民围村8组17号","民围村村委会","杭州市萧山区益农镇兴裕村村委会","杭州市萧山区益农镇东江村村委会","杭州市萧山区益农镇三围村村委会","杭州市萧山区临浦镇蔡东藩社区万安路29号","杭州市萧山区临浦镇东麓池社区峙山北路65号","杭州市梅城镇总府社区府前街52号","杭州市桐庐县钟山乡大市村","杭州市桐庐县百江镇紫燕路777号文体中心201室","杭州市桐庐县百江镇小京村小京口","杭州市桐庐县瑶琳镇便民服务中心","杭州市桐庐县江南镇金浦路228号","杭州市桐庐县横村镇龙伏村村委","杭州市桐庐县横村镇独山社区退役军人服务站二楼","杭州市桐庐县横村镇横政路299号一楼","杭州市桐庐县横村镇城东村村委","杭州市桐庐县横村镇双溪村文化礼堂","杭州市桐庐县横村镇上唐村村委205室","杭州市桐庐县桐君街道迎春街55号桐君街道办事处1楼司法所","杭州市桐庐县桐君街道迎春街2幢大院内迎春社区","杭州市桐庐县桐君街道洋塘路98号102室","杭州市桐庐县桐君街道富春路543号1楼","杭州市桐庐县桐君街道天目路186号二楼办公室","杭州市桐庐县桐君街道圆通路22号圆通社区2楼","杭州市桐庐县桐君街道南门弄85号南门社区1楼","杭州市桐庐县桐君街道劳动路106号301室","杭州市桐庐县旧县街道港桐路29号","杭州市桐庐县富春江镇黄坡岭社区大楼","杭州市桐庐县富春江镇金家村村委大楼","杭州市桐庐县富春江镇象山桥村村委大楼","杭州市桐庐县富春江镇茆坪村村委大楼","杭州市桐庐县富春江镇芝厦村村委大楼","杭州市桐庐县富春江镇石舍村村委","杭州市桐庐县富春江镇渡济村村委大楼","杭州市桐庐县富春江镇孝门村村委大楼","杭州市桐庐县富春江镇大洋坪社区办公楼","杭州市桐庐县富春江镇大庄畲族村村委大楼","杭州市桐庐县富春江镇俞赵村村委大楼","杭州市桐庐县富春江镇严陵村村委大楼","杭州市桐庐县富春江镇上泗村村委大楼","杭州市桐庐县富春江镇七里泷村村委大楼","杭州市桐庐县城南街道金牛村文化礼堂","杭州市桐庐县城南街道迎春南路303号","杭州市桐庐县城南街道办事处副楼1-103","杭州市桐庐县合村乡社会治理中心","杭州市桐庐县合村乡岭源村村委楼204室","杭州市桐庐县合村乡合村村村委楼202室","杭州市桐庐县分水镇院士路98号矛调中心一楼102室","杭州市桐庐县分水镇里湖村村委一楼102室","杭州市桐庐县分水镇砖山村创业楼一楼101室","杭州市桐庐县分水镇百岁坊村村委一楼302室","杭州市桐庐县分水镇桥东村村委二楼301室","杭州市桐庐县分水镇大路村村委二楼203室","杭州市桐庐县凤川街道梅林路699号凤川街道办事处","杭州市拱墅区长庆街道柳营社区柳营巷22号矛调中心二楼","杭州市拱墅区米市巷街道红石板社区沈塘东村2-5号社区二楼","杭州市拱墅区石桥街道景安社区北景竹邻苑10幢4单元1楼","杭州市拱墅区潮鸣街道知足弄社区潮鸣寺巷11号","杭州市拱墅区湖州街198号主楼106室","杭州市拱墅区武林街道竹竿巷社区竹竿巷8号3楼理论宣教室","杭州市拱墅区朝晖街道玉公桥社区朝晖二小区26幢西三楼平安建设办公室","杭州市拱墅区映月社区长阳路330号","杭州市拱墅区文晖街道三里家园社区三里家园一小区26幢2层","杭州市拱墅区拱宸桥街道上塘路845号二楼","杭州市拱墅区天水街道百井坊巷81号社会治理综合服务中心二楼","杭州市拱墅区大关街道东二社区大关东八苑4幢底层","杭州市拱墅区和睦街道和睦社区和睦新村49-1号","杭州市拱墅区半山街道龙山社区半山东路田园牧歌麓云苑5幢沿街龙山社区","杭州市拱墅区半山街道半山社区版山路3号半山街道综合治理服务中心1楼","杭州市拱墅区仓基新村66幢矛调中心一楼","杭州市拱墅区东新街道西文街太阳马戏东下沉广场东新街道矛条中心关爱工作室","杭州市拱墅区上塘街道红建河社区沈半路三号","杭州市建德市钦堂乡钦堂路27号便民服务中心2楼202室","杭州市建德市莲花镇莲花村刘家186号莲花镇政府一楼综合信息指挥室110室室","杭州市建德市航头镇溪沿村警网综治中心一楼","杭州市建德市洋溪街道洋溪社区老街","杭州市建德市杨村桥镇人民政府一楼101室","杭州市建德市李家镇金石路一号政府大院二楼","杭州市建德市新安江街道明珠社区明珠路1号","杭州市建德市新安江街道新安路2号矛调中心二楼218室","杭州市建德市寿昌镇中山路38号15号楼4楼","杭州市建德市大洋镇矛调中心二楼208室","杭州市建德市大慈岩镇荷花路10号","杭州市建德市大同镇人民政府矛调中心","杭州市建德市乾潭镇陵上新村","杭州市建德市下涯镇江湾村文化礼堂","杭州市建德市三都镇绿源村村民委员会","杭州市建德市三都镇梓里村村民委员会","杭州市富阳区鹿山街道蒋家村工农路146号","杭州市富阳区银湖街道高桥东路1号","杭州市富阳区胥口镇胥口村85号","杭州市富阳区环山乡环龙路1号","杭州市富阳区灵桥镇灵礼路1号","杭州市富阳区渔山乡渔山村朱亩畈55号","杭州市富阳区渌渚镇岘口村新建路68号","杭州市富阳区洞桥镇洞桥头桥上52号","杭州市富阳区春江街道蔡伦路8号","杭州市富阳区春建乡春建村吴家滩1号","杭州市富阳区新登镇城北路32号","杭州市富阳区常安镇大田村1号","杭州市富阳区富春街道达夫路121号","杭州市富阳区富春街道桂花路28号","杭州市富阳区大源镇花果山路23号","杭州市富阳区场口镇百丈畈1号","杭州市富阳区东洲街道中桥路7号","杭州市富阳区万市镇政府路8号","杭州市余杭区闲林街道闲富中路2号","杭州市余杭区闲林东路5号","杭州市余杭区闲林东路5号","杭州市余杭区余杭街道凤新路路356号综治中心","杭州市余杭区仓前街道龙潭路22号社会治理中心二楼","杭州市余杭区仓前街道葛巷社区26-1","杭州市临平区运河街道东湖北路653号","杭州市临平区星桥街道社会服务管理中心二楼","杭州市临平区崇贤街道崇杭街117号崇贤司法所2楼202室","杭州市临平区塘栖镇人民路30号","杭州市临平区南苑街人民大道792号道办事处105室","杭州市临平区乔司街道综治中心3楼304室","杭州市临平区临平街道北沙东路50号","杭州市临平区东湖街道办事处裙楼105室","杭州市临安区龙岗镇人民政府","杭州市临安区高虹镇高虹大街狮子山路50号","杭州市临安区青山湖街道鹤亭街1551号社会治理中心","杭州市临安区锦城街道青龙社区邻里中心(翠浪路与胡村街岔路口)","杭州市临安区锦城街道衣锦街468号","杭州市临安区锦南街道杨岱村锦天路375号","杭州市临安区锦北街道北排街261号","杭州市临安区秀溪村坑口51号","杭州市临安区玲珑街道夏禹桥村夏禹街29号玲珑街道办事处新大楼调解室","杭州市临安区潜川镇乐平村矛调中心常乐街10号","杭州市临安区湍口镇矛调中心一楼西侧","杭州市临安区清凉峰镇颊口村桥东农贸市场二楼","杭州市临安区河桥镇柳溪街19号","杭州市临安区板桥镇下板桥7号","杭州市临安区昌化镇西大街58号矛调中心二楼","杭州市临安区於潜镇人民街48号","杭州市临安区岛石镇矛调中心岛石街115号","杭州市临安区太阳大街161号综治中心一楼","杭州市临安区太湖源镇青溪街251号","杭州市临安区天目山镇人民政府藻溪环河北街68号","杭州市上城区闸弄口街道麦苗社区三里家园三小区17幢一楼麦苗社区","杭州市上城区闸弄口街道闻皇庙社区里新城桂苑综合楼二楼","杭州市上城区闸弄口街道闸弄口社区横路30号闸弄口社区居委会","杭州市上城区闸弄口街道蓝天社区蓝天城市花园3-103室","杭州市上城区闸弄口街道红梅社区三里亭苑4区17幢","杭州市上城区闸弄口街道濮家联合社区濮家井2号","杭州市上城区闸弄口街道春晖社区三里亭苑二区15-1幢春晖社区办公楼 ","杭州市上城区闸弄口街道天运社区秋涛北路248号三华天运花园16幢一","杭州市上城区闸弄口街道天仙社区铭苑路77号","杭州市上城区闸弄口街道兰苑社区机场路一巷109号兰苑社区居委会","杭州市上城区闸弄口街道京惠社区京惠花园11—12幢附3楼","杭州市上城区闸弄口街道上城区闸弄口街道濮家井27号","杭州市上城区闸弄口街道三里亭社区三里亭东苑11号楼三楼","杭州市上城区闸弄口街道万家花园社区天城路95号万和苑5幢底层","杭州市上城区笕桥街道草庄社区机场路188号(草庄景墅内12幢斜对面社区办公楼2楼)","杭州市上城区笕桥街道笕桥社区笕桥路3-1号笕桥社区居民委员会","杭州市上城区笕桥街道同心社区居委会1楼","杭州市上城区湖滨街道青年路社区见仁里45号","杭州市上城区湖滨街道东平巷社区羊血弄10号","杭州市上城区清波街道柳翠井巷社区光复路50号","杭州市上城区清波街道定安路社区后市街121号","杭州市上城区望江街道近江西园社区衢江路153号","杭州市上城区新工社区新工大道7号楼","杭州市上城区彭埠街道茶亭苑社区德信东望7幢底商","杭州市上城区彭埠街道红五月社区艮山东路108号","杭州市上城区彭埠街道皋塘社区新塘路325号","杭州市上城区彭埠街道王家井社区新风丽都北苑","杭州市上城区彭埠街道建华社区建华嘉苑9幢底商","杭州市上城区彭埠街道备塘中路7号矛调中心二楼202室","杭州市上城区彭埠街道六堡社区四号港路与御景路南150米","杭州市上城区彭埠街道七堡社区五号港路","杭州市上城区小营街道金钱巷社区严衙弄35幢3单元1楼","杭州市上城区四季青街道钱江苑社区钱环路100号","杭州市上城区四季青街道钱塘社区庆和路2号","杭州市上城区凯旋街道金秋花园社区凤起东路55号","杭州市上城区凯旋街道景苑社区昙花庵路205号景苑公寓1幢108室","杭州市上城区凯旋街道景昙路134号公共服务中心二楼","杭州市上城区九堡街道金堡街51号二楼兴安社区服务中心","杭州市上城区九堡街道通盛路30号旁江涛社区服务中心","杭州市上城区九堡街道红苹果社区泊林印象1幢底商3号服务中心","杭州市上城区九堡街道格畈社区九盛路33号服务中心","杭州市上城区九堡街道新江花园社区新江花园小区24幢一楼服务中心","杭州市上城区九堡街道宣家埠村宣家埠三区36号宣家埠村委会","杭州市上城区九堡街道友爱路232号社会治理综合服务中心1楼","杭州市上城区九堡街道九塘社区和睦港路1号服务中心","杭州市上城区九堡街道九堡街道景蓝社区蓝桥景苑小区服务中心","杭州市上城区九堡街道三卫社区红普路和科城街交叉口三卫办公楼","杭州市上城区临丁路699号丁兰司法所115室","杭州市上城区丁兰街道长虹社区阳光逸城11幢底层","杭州市上城区丁兰街道长睦苑社区长虹路576号二楼","杭州市上城区丁兰街道美辰社区华丰中路34号辰秀嘉园南区3幢1楼","杭州市上城区丁兰街道白马庄社区长睦锦苑3幢2楼","杭州市上城区丁兰街道明珠社区美邻嘉苑15幢1楼","杭州市上城区丁兰街道建塘苑社区康华路520号","杭州市上城区丁兰街道后珠苑社区后珠家苑10幢2楼","杭州市上城区丁兰街道同协苑社区华丰中路856号","杭州市上城区丁兰街道华鹤社区华鹤街584号","杭州市上城区丁兰街道五会港社区明珠街1293号","杭州市上城区丁兰街道丁兰社区丁群街432号","春波路646号","星民社区居委会","新赏社区","新街街道办事中心2楼","新盛村村委","新润社区","新宜社区","新塘头村村委","新和社区","文昌镇潭头村33号108室","拱墅区小河街道娑婆桥社区和睦路128号一楼","左口乡龙源庄村","左口乡桥西村龙坑坞1-1","山末址村村委","屏门乡屏门村1号","屏门乡佛岭后村党群服务中心","富文乡富文村96号","安阳乡党群服务中心","威坪镇兴华街321号","姜家镇黄村桥村民委员会","姜家镇狮城路110号","姜家镇桂溪村民委员会","姜家镇墨香湖社区物业楼","姜家镇双溪村民委员会","奥体社区居委会扬帆路龙湖春江彼岸","天杭社区闸弄口横路46号","天官东路115-117号","大墅镇府前路11号","大墅村村委楼","城厢街道萧西路845号","城厢街道百尺溇路72号","城厢街道水城37幢二楼社区居委会内","城厢街道山阴路2180号","同兴村村委","双圩村村委","协同社区居委会滨江区风情大道与滨和路交叉口西140米","千岛湖镇新塘路92号117室","千岛湖镇南苑社区","千岛湖镇人民政府","冠山小区38幢北侧商铺","元沙村村委","儒洪村村委楼","余杭区黄湖镇迂前南路95号","余杭区良渚街道莫干山路2666号良渚街道办事处7号楼左侧103室","余杭区瓶窑镇前程路28号","余杭区径山镇龙皇路12号径山镇人民政府社会治理中心二楼","余杭区仁和街道综治中心313室","余杭区五常街道西坝路59号街道办事处1号楼二楼204室","余杭区中泰街道杭泰路158号","义桥镇湘南村党群服务中心","义桥镇渔浦社区党群服务中心","义桥镇復兴村党群服务中心","义桥镇云峰村党群服务中心","义桥镇七里店村党群服务中心","义桥镇丁家庄村党群服务中心","临岐镇鱼市街51号","临岐镇右源村村委大楼","中洲镇人民政府平安办办公室","中洲镇中洲村村委楼","上城区南星街道海月桥社区复兴南街238号南星街道矛调中心" };
public static void main(String[] args) throws UnsupportedEncodingException {
for (int i = 0; i < keywordArr.length; i++) {
// if (!keywordArr[i].equals("龙井路26号")) {
String strResult = doGet(keywordArr[i]);
System.out.println("输出结果=====" + strResult);
// } else {
// System.out.println("输出结果=====");
// }
}
}
/**
* GET请求.
*
* @param keywords 请求地址
* @return 响应数据
*/
public static String doGet(String keywords) throws UnsupportedEncodingException {
String url = "https://lbs.amap.com/_AMapService/v3/place/text?s=rsv3&children=&key=f7d40927ba4d64fb91ebe2bb9cda0995&offset=1&page=1&extensions=all&city=330100&language=zh_cn&callback=jsonp_379279_&platform=JS&logversion=2.0&appname=https%3A%2F%2Flbs.amap.com%2Ftools%2Fpicker&csid=55C4C1D6-2EAF-46B1-9FA8-B13C3247DD4F&sdkversion=1.4.19";
url += "&keywords="+ URLEncoder.encode(keywords, "UTF-8");
try {
// 创建客户端
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// 建立连接
HttpGet httpGet = new HttpGet(url);
// 请求配置:超时时间,单位:毫秒
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build();
httpGet.setConfig(requestConfig);
// 设置请求头:内容类型
httpGet.setHeader(":authority", "lbs.amap.com");
httpGet.setHeader(":method", "GET");
httpGet.setHeader(":path", "/_AMapService/v3/place/text?s=rsv3&children=&key=f7d40927ba4d64fb91ebe2bb9cda0995&offset=1&page=1&extensions=all&city=330100&language=zh_cn&callback=jsonp_141787_&platform=JS&logversion=2.0&appname=https%3A%2F%2Flbs.amap.com%2Ftools%2Fpicker&csid=3009ADA5-C43B-43B1-AD1B-2B04A6A9153D&sdkversion=1.4.19&keywords=%E6%B1%9F%E5%8D%97%E6%9D%91%E6%9D%91%E5%A7%94%E5%8A%9E%E4%BA%8B%E5%A4%A7%E5%8E%85");
httpGet.setHeader(":scheme", "https");
httpGet.setHeader("accept", "*/*");
httpGet.setHeader("accept-encoding", "gzip, deflate, br");
httpGet.setHeader("accept-language", "zh-CN,zh;q=0.9");
httpGet.setHeader("cookie", "cna=7/fsGsW7wGMCATy6blU+7Og0; xlly_s=1; _uab_collina=165525416175852275352082; tfstk=cImABNbgOQADYay-LqLubRQIrAg1CP6YstNOXcNAZDrkYZhjg01mxDmKV28bQWPve; l=eBNe89p7L6FiSeaMBO5Bourza779ZUAbfPVzaNbMiInca1kVjeDIQNChfn6MKdtjgtfeqnxP0_Wjjdnk-O4dgBEhBJIqhySKtxJw-; isg=BHBwiTtu5tpum7reMVtrKKzmQT7CuVQDqbnWD2rbfUuGJQ_PDMh8k7tTfS1FsAzb");
httpGet.setHeader("referer", "https://lbs.amap.com/tools/picker");
httpGet.setHeader("sec-ch-ua-mobile", "?0");
httpGet.setHeader("sec-fetch-dest", "script");
httpGet.setHeader("sec-fetch-mode", "no-cors");
httpGet.setHeader("sec-fetch-site", "same-origin");
httpGet.setHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"); httpGet.setHeader("Content-Type", "application/json;charset=UTF-8");
return getResponse(httpClientBuilder, httpGet);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
/**
* 获取GET请求数据.
*
* @param httpClientBuilder 客户端对象
* @param httpGet GET请求
* @return 响应数据
*/
public static String getResponse(HttpClientBuilder httpClientBuilder, HttpGet httpGet) throws IOException {
if (Objects.nonNull(httpClientBuilder) && Objects.nonNull(httpClientBuilder.build())) {
CloseableHttpResponse closeableHttpResponse = httpClientBuilder.build().execute(httpGet);
if (Objects.nonNull(closeableHttpResponse)) {
HttpEntity httpEntity = closeableHttpResponse.getEntity();
if (Objects.nonNull(httpEntity)) {
String resp = EntityUtils.toString(httpEntity, "UTF-8");
if (StringUtils.isNotBlank(resp)) {
String json = resp.substring(14, resp.length() -1);
if (StringUtils.isNotBlank(json)) {
HashMap map = JSONObject.parseObject(json, HashMap.class);
if (CollectionUtil.isNotEmpty(map)) {
List<Map<String, String>> mapList = (List<Map<String, String>>) map.get("pois");
if (CollectionUtil.isNotEmpty(mapList) && mapList.size() > 0 ) {
Map<String, String> object = mapList.get(0);
if (Objects.nonNull(object)) {
String location = (String) object.get("location");
if (StringUtils.isNotBlank(location)) {
return location;
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
} else {
return "";
}
}
}