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
版权声明:
本文来源网络,所有图片文章版权属于原作者,如有侵权,联系删除。
本文网址:https://www.bianchenghao6.com/java-jiao-cheng/6687.html