[英]Jsoup Remove the link href attribute starts with Href
我想删除从http://goo.gl到https://goo.gl的链接href属性。
以下是我的代码,但并非完全没有错误消息。
我不知道该怎么办。 请帮我。
public class NewClass {
public static void main(String[] args) {
try {
Document connect = Jsoup.connect("http://blogtamsu.vn/ngoc-trinh-duoc-goi-la-hinh-mau-bao-hieu-tot-doi-dep-dao.html").get();
Elements selects = connect.select("div.remain_detail");
String levels = "a[href^=http://goo.gl],a[href^=https://goo.gl]";
for (String level : levels.split(",")) {
selects.remove(level);
}
System.out.println(Jsoup.clean(selects.html(), Whitelist.relaxed()));
} catch (IOException ex) {
Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
使用regex
选择和从selects
删除:
selects.select("a[href~=(http|https)://goo.gl]").remove()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.