HttpClient类访问接口学习
String url = "http://www.weather.com.cn/data/sk/101210101.html";
HttpClient httpClient = new HttpClient();//获取客户端
httpClient.getParams().setContentCharset("UTF-8");//设置编码
GetMethod method = new GetMethod(url);//get请求
// method.addParameter("city", "%B1%B1%BE%A9");
// method.addParameter("password", "DJOYnieT8234jlsK");
// method.addParameter("tel", "13429260609");
httpClient.executeMethod(method);//发送请求
String result = method.getResponseBodyAsString();//获取请求返回的数据
JSONObject json = JSONObject.fromObject(result);
JSONObject joa = JSONObject.fromObject(json.get("weatherinfo"));
System.out.println(joa.get("WD"));
method.releaseConnection();//关闭连接