【发布时间】:2015-09-06 14:55:39
【问题描述】:
我一直在尝试抓取一个网站并从中获取一些数据。我要爬的网页是这个:http://www.oddsportal.com/soccer/england/premier-league/everton-chelsea-4tRin4kn/ 我对获取页面中间表格中的数字特别感兴趣。我尝试通过打印 html 代码以最基本的方式对其进行爬网,然后我的想法是在 html 中搜索数字并将它们保存在文件中。问题是我在 html 中的任何地方都找不到这些数字。即使我在浏览器中打开它并单击显示源代码,我仍然找不到它们。这是我正在使用的代码。
private static String getUrlSource(String url) throws IOException {
URL yahoo = new URL(url);
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream(), "UTF-8"));
String inputLine;
StringBuilder a = new StringBuilder();
while ((inputLine = in.readLine()) != null)
a.append(inputLine);
in.close();
return a.toString();
}
任何关于如何从表中获取数据的建议将不胜感激!
【问题讨论】:
标签: java html web-crawler webpage