-3
我一直在JSoup工作和測試一段時間,這個問題已經困擾了我一段時間。試圖從網站提取信息,但有些值顯示爲空?
http://fx.sauder.ubc.ca/today.html
目前這個類是從本網站應該提取信息從一個表中的唯一的東西,這個程序可以從表中拉是
Code | Currency | fcu/CAD | fcu/USD | Code | Currency | fcu/CAD | fcu/USD
和所有上顯示的3個字母的代碼該網站,但對於所有其他信息,如價值和美元名稱程序顯示這些爲空。如果任何人想知道px會上升到34,並且ay會上升到16,因爲這是我將從中提取的表的大小。
public String CountryHandler2(int px, int ay) throws IOException{
String url = "http://fx.sauder.ubc.ca/today.html";
Document doc = Jsoup.connect(url).get();
Elements paragraphs = doc.select("body > table:nth-child(4) > tbody:nth-child(1) > tr:nth-child("+px+") > td:nth-child("+ay+") > font:nth-child(1) > b:nth-child(1)");
System.out.println("Paragraphs " + paragraphs.text());
if(paragraphs.hasText()){
return paragraphs.text();
}
return null;
}
請製作[mcve]。在這裏沒有辦法幫助你,因爲我們在問題本身沒有必要的信息。另見[問]。 – Tunaki