Advertisement
lutzmor

yay

May 11th, 2021
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. public static String parseAdvisory(String html) {
  2.         if(html == null || StringUtils.isEmpty(html)) {
  3.             return "";
  4.         }
  5.        
  6.         String result = html;  
  7.         Document doc = Jsoup.parse(html);
  8.         Elements select = doc.select("a[href]");
  9.         result = Jsoup.clean(html, Whitelist.simpleText());
  10.        
  11.         for(Element currElement: select) {
  12.             String url = currElement.attr("abs:href");
  13.             String urlText = select.text();
  14.             result = result.replaceAll(urlText, urlText + " (" + url + ")");
  15.         }
  16.        
  17.         return result;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement