Zim*_*Zim 5 html java parsing jsoup
可能是一个不明确的问题,所以这里是代码和解释:
Document doc = Jsoup.parse(exampleHtmlData);
Elements certainLinks = doc.select("a[href=google.com/example/]");
Run Code Online (Sandbox Code Playgroud)
String exampleHtmlData包含来自特定站点的已解析HTML源.这个网站有很多链接指导用户谷歌.一些例子是:
http://google.com/example/hello
http://google.com/example/certaindir/anotherdir/something
http://google.com/anotherexample
Run Code Online (Sandbox Code Playgroud)
我想在doc.select函数的链接中提取包含google.com/example/的所有链接.我如何使用JSoup做到这一点?
您可以参考SelectorSyntax.
Document doc = Jsoup.parse(exampleHtmlData);
Elements certainLinks = doc.select("a[href*=google.com/example/]");
Run Code Online (Sandbox Code Playgroud)