【问题标题】:How to print data from a webpage? Not the html code of the page.如何从网页打印数据?不是页面的html代码。
【发布时间】:2013-12-19 16:46:06
【问题描述】:

在 java 中,我正在尝试阅读网页。我只想打印页面的数据。但我的代码正在打印整个 html 代码。看起来很奇怪。我可以看到我想要它隐藏在 html 中的确切数据。如何摆脱打印 html 代码? 这是我的代码:

URL url = new URL("http://www.rxbd.info/Controller/Controller?action=details&drug=zorubicin&group=generic");
URLConnection con = url.openConnection();
InputStream is =con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null ) {
    System.out.println(line);
}

【问题讨论】:

    标签: java html printing webpage


    【解决方案1】:

    看看JerichoRenderer 类可以将原始 HTML 渲染为文本,TextExtractor 类可以只提取文本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-29
      • 2011-11-01
      • 2023-04-04
      • 2012-04-07
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 2012-04-22
      相关资源
      最近更新 更多