您好,欢迎来到九壹网。
搜索
您的当前位置:首页text html text plain,java - how to convert HTML text to plain text? - Stack Overflow

text html text plain,java - how to convert HTML text to plain text? - Stack Overflow

来源:九壹网

If you want to parse like browser display, use:

import net.htmlparser.jericho.*;

import java.util.*;

import java.io.*;

import java.net.*;

public class RenderToText {

public static void main(String[] args) throws Exception {

String sourceUrlString="data/test.html";

if (args.length==0)

System.err.println("Using default argument of \""+sourceUrlString+'"');

else

sourceUrlString=args[0];

if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;

Source source=new Source(new URL(sourceUrlString));

String renderedText=source.getRenderer().toString();

System.out.println("\nSimple rendering of the HTML document:\n");

System.out.println(renderedText);

}

}

I hope this will help to parse table also in the browser format.

Thanks,

Ganesh

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务