当前位置:网站首页 > 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

版权声明


相关文章:

  • eclipse开发java教程2025-03-13 15:34:00
  • 刷石器教程java版2025-03-13 15:34:00
  • java教程牛客2025-03-13 15:34:00
  • 帆软java教程2025-03-13 15:34:00
  • java数据教程2025-03-13 15:34:00
  • java新手 使用教程2025-03-13 15:34:00
  • java405卸载教程2025-03-13 15:34:00
  • java画玫瑰教程2025-03-13 15:34:00
  • java框架教程云盘2025-03-13 15:34:00
  • java测试 教程2025-03-13 15:34:00