我想从http://www.etnet.com.hk/www/eng/stocks/realtime/quote.php?code=700
获得股票价格(例如.193.600)我有以下代码:
private String url = "http://www.etnet.com.hk/www/eng/stocks/realtime/quote.php?code=700";
Elements answerers = document.select("div.data-row div.C.font28.C.bold .span .span");
但它只返回null
我也试过了 Elements answerers = document.select(“td.styleA span.Price.down2”); 返回 跑: 空值 建立成功(总时间:0秒)
和 Elements answerers = document.select(“td.styleA”); 返回 跑: 建立成功(总时间:0秒)
答案 0 :(得分:0)
使用此CSS选择器:
Elements answerers = document.select("td.up, td.down");
答案 1 :(得分:0)
public static void main(String args[]) throws IOException {
String url = "http://www.etnet.com.hk/www/eng/stocks/realtime/quote.php?code=700";
Document doc = Jsoup.connect(url).get();
Element table = doc.select("table[class=figureTable]").first();
Iterator<Element> iterator = table.select("td[align=right]").iterator();
iterator.next();// this is nominal column
iterator.next();// this is turnover column
System.out.println(iterator.next().text());
System.out.println(iterator.next().text());
System.out.println(iterator.next().text());
System.out.println(iterator.next().text());
System.out.println(iterator.next().text());
}