我有以下的HTML代碼:Java HTML解析沒有得到我的數據?
<tr class="odd">
<td class="first name">
<a href="/quote/III:LN">3i Group PLC</a>
</td>
<td class="value">457.80</td>
<td class="change up">+10.90</td> <td class="delta up">+2.44%</td> <td class="value">1,414,023</td>
<td class="datetime">11:35:08</td>
因我所需要得到的數據
457.80
(即value屬性),我有這樣的Java代碼目前:
String FTSE = "http://www.bloomberg.com/quote/UKX:IND/members";
doc = Jsoup.connect(FTSE).get();
Elements links = doc.select("a[href='/quote/III:LN']");
for (Element link : links) {
// get the value from href attribute
System.out.println("\nlink : " + link.attr("value"));
System.out.println("text : " + link.text());
當我運行我的程序時,它終止輸出什麼都沒有。我如何製作它,以便它輸出值,在這種情況下,它是'457.80'?
我認爲你沒有使用正確的選擇。而不是「a [href ='/ quote/III:LN']」嘗試「td.value」。 – Titus 2014-12-07 18:46:09