package api.jisuapi.oil; import java.net.URLEncoder; import api.util.HttpUtil; import net.sf.json.JSONObject; public class Query { public static final String APPKEY = "your_appkey_here";// 你的appkey public static final String URL = "https://api.jisuapi.com/oil/query"; public static final String province = "河南";// utf-8 public static void Get() throws Exception { String result = null; String url = URL + "?appkey=" + APPKEY + "&province=" + URLEncoder.encode(province, "utf-8"); try { result = HttpUtil.sendGet(url, "utf-8"); JSONObject json = JSONObject.fromObject(result); if (json.getInt("status") != 0) { System.out.println(json.getString("msg")); } else { JSONObject resultarr = json.optJSONObject("result"); String province = resultarr.getString("province"); String oil90 = resultarr.getString("oil90"); String oil93 = resultarr.getString("oil93"); String oil97 = resultarr.getString("oil97"); String oil0 = resultarr.getString("oil0"); String updatetime = resultarr.getString("updatetime"); System.out.println(province + " " + oil90 + " " + oil93 + " " + oil97 + " " + oil0 + " " + updatetime); } } catch (Exception e) { e.printStackTrace(); } } }