查邮编
如查询北京市东城区长安街的邮编,可以通过以下地址查询
http://cpdc.chinapost.com.cn/web/index.php?m=postsearch&c=index&a=ajax_addr&searchkey=北京市东城区长安街 |
返回json串格式化后为,rs对应的数组为该地址对应的邮编,可以按需求选取
{ "su": true, "errcode": 0, "rs": [ { "ADDR": "北京市密云县长安街0", "POSTCODE": "101599" }, { "ADDR": "北京市密云县长安街10号", "POSTCODE": "101599" }, { "ADDR": "北京市密云县长安街11号", "POSTCODE": "101599" } ], "pageinfo": { "CURRENTPAGE": "1", "TOTALPAGE": "1", "ITEMCOUNT": 3 }, "searchkey": "北京市东城区长安街", "checkcode": true, "now_num": 3, "pageshtml": "" } |
当查询的地址不存在时,如随便输入的字母串adsaffgrjdg
http://cpdc.chinapost.com.cn/web/index.php?m=postsearch&c=index&a=ajax_addr&searchkey=adsaffgrjdg |
返回体如下,此时rs对应数组为空数组
{ "su": true, "errcode": 0, "rs": [ ], "pageinfo": { "CURRENTPAGE": "0", "TOTALPAGE": "0", "ITEMCOUNT": 0 }, "searchkey": "adsaffgrjdg", "checkcode": true, "now_num": 0, "pageshtml": "" } |
调用接口方式网上一搜一大堆,这里只写个供参考,传入参数为拼接后的 地址即可
public static String getConnection(String path) throws Exception{
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
BufferedReader reader = new BufferedReader(new inputstreamreader(connection.getInputStream(),"UTF-8"));
String line ;
stringbuilder sb = new StringBuilder();
while((line=reader.readLine())!=null){
sb.APPend(line);
}
connection.disconnect();
return sb.toString();
}
相关阅读
ARCGIS破解教程(arcgis10.2(含ARCGIS下载地址)
准备工具:arcgis软件(arcgis下载地址:百度网盘 http://pan.baidu.com/s/1i5uMzU9 QQ网盘:https://share.weiyun.com/5VFcdG
https://open.unionpay.com/ajweb/help/file/techFile?productId=1
随着电商时代的到来,很多实体店商家都关闭了自己的线下店铺,转战线上。然而,阿里却玩起了线下实战,推出了新零售体验,先是推出了天猫新
现在有很多大学生、宝妈或者是自由职业都喜欢去seo实验室宝店,但是大家又对联系地址如何填写还不明白。那么今天小编就来为大家解
一些卖家需要把宝贝放在淘宝站外的网站上推广,这时候很多卖家朋友可能不清楚如何提取无线的链接地址,更不知道宝贝url地址是什么,所