中华万年历api
public static String GetWeatherData(String cityname) {
StringBuilder sb=new StringBuilder();
try {
String weatherUrl = "http://wthrcdn.etouch.cn/weather_mini?city="+cityname;
URL url = new URL(weatherUrl);
URLConnection conn = url.openConnection();
InputStream inputStream = conn.getInputStream();
GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream);
// 设置读取流的编码格式,自定义编码
InputStreamReader inputStreamReader = new InputStreamReader(gzipInputStream, "utf-8");
BufferedReader reader = new BufferedReader(inputStreamReader);
String line = null;
while((line=reader.readLine())!=null)
sb.append(line+" ");
reader.close();
} catch (Exception e) {
System.out.println("异常了");
e.printStackTrace();
}
return sb.toString();
}