网页中正文提取之----joyhtml
import java.net.URL;import org.cyberneko.html.parsers.DOMParser;import org.joy.analyzer.html.TextExtractor;import org.w3c.dom.Document;import org.xml.sax.InputSource;public class Test {public static void main(String[] args) throws Exception {DOMParser parser = new DOMParser();String url = "http://finance.people.com.cn/n/2013/1011/c66323-23157265.html";parser.parse(new InputSource(new URL(url).openStream()));Document doc = parser.getDocument();TextExtractor extractor = new TextExtractor(doc);String str = extractor.extract();System.out.println(str);}}
?
? ?依赖的lib参见附件?
?