Java实时获取天气(免费接口)
/** 天气URL/
public static final String TQ_URL="https://tianqiapi.com/api.php";
//TODO https://tianqiapi.com/api.php?style=tq //有更多内容
/** 抽取参数空格符/
public static final String K_G="\u3000";
Calendar now = Calendar.getInstance();
String html = HttpClientUtil.getFromUrl(TQ_URL,null);
Document doc = Jsoup.parse(html);
Elements rows = doc.select("em");
String rtn = rows.get(0).text()+K_G+rows.get(1).text()+K_G+rows.get(2).text();
String paramValue = "今天是:"+now.get(Calendar.YEAR)+"年"+(now.get(Calendar.MONTH) + 1)+"月"+now.get(Calendar.DAY_OF_MONTH)+"日"+K_G+week+K_G+rtn;
(效果见附图)
以上是 Java实时获取天气(免费接口) 的全部内容, 来源链接: utcz.com/z/390705.html