当前位置:网站首页 > Java教程 > 正文

java htmlparser 使用教程



I'm very much a Java novice. For my class we have to print out all of the links that are to be parsed from a user-inputted html source code.

Basically, I want to figure out how to take the string of the link that comes after the href attribute and do that for all links on the webpage, without using external methods (i.e. using arrays, substrings, and methods of strings but not importing other libraries).

解决方案

Don't do it with Parser or RegExp. Try Jerry. Like (not tested):

Jerry doc = jerry(html);

doc.$("a").each(new JerryFunction() {

public boolean onNode(Jerry $this, int index) {

String href = $this.attr("href");

System.out.println(href);

}

}

or any html-friendly query language. Because of non-externals requirements try Trying to parse links in an HTML directory listing using Java

  • 上一篇: java基础教程入门
  • 下一篇: 374集java教程
  • 版权声明


    相关文章:

  • java基础教程入门2025-01-28 21:10:02
  • java怎么设置教程2025-01-28 21:10:02
  • 鸿蒙教程java2025-01-28 21:10:02
  • java加水印教程2025-01-28 21:10:02
  • java maven菜鸟教程2025-01-28 21:10:02
  • 374集java教程2025-01-28 21:10:02
  • java全站压缩教程2025-01-28 21:10:02
  • java redis教程pdf2025-01-28 21:10:02
  • java研发教程2025-01-28 21:10:02
  • java 多线程教程2025-01-28 21:10:02