【发布时间】:2016-05-30 16:27:22
【问题描述】:
我已经使用 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;
}
【问题讨论】:
-
请发送minimal reproducible example。由于我们在问题本身中没有必要的信息,因此无法在这里为您提供帮助。另见How to Ask。