0
我試圖從谷歌網頁得到天氣情況,並有一個標籤上的HTML元素wob_tm
,我試圖得到的價值,但總是我得到一個異常使用JSoup刮谷歌天氣結果
try {
Document document = Jsoup.connect("https://www.google.jo/webhp?hl=en#hl=en-JO&q=amman+weather").get();
Element temp = document.getElementById("wob_tm");
System.out.println(temp.text()); // Exception in thread "main" java.lang.NullPointerException
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
你得到了什麼異常? – luksch
'NullPointerException' – tamtom
您是否嘗試將整個文檔打印到您的LogCat以檢查您實際獲得的內容? – freddieptf