当前位置:网站首页 > 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.\((&#34;a&#34;).each(new JerryFunction() {</p> <p>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基础教程入门2026-01-15 11:42:01
  • java怎么设置教程2026-01-15 11:42:01
  • 鸿蒙教程java2026-01-15 11:42:01
  • java加水印教程2026-01-15 11:42:01
  • java maven菜鸟教程2026-01-15 11:42:01
  • 374集java教程2026-01-15 11:42:01
  • java全站压缩教程2026-01-15 11:42:01
  • java redis教程pdf2026-01-15 11:42:01
  • java研发教程2026-01-15 11:42:01
  • java 多线程教程2026-01-15 11:42:01