I want to parse this link :
<a href="http://www.google.fr">Link to google</a>
In order to get two results:
Link = "http://www.google.fr"
LinkName = "Link to google"
I really don't know how to do this, is there a library in Java to solve this problem ?
Thanks in advance,
Use jsoup parser:
example:
File input = new File("/tmp/input.html");
Document doc = Jsoup.parse(input, "UTF-8", "http://example.com/");
Element content = doc.getElementById("content");
Elements links = content.getElementsByTag("a");
for (Element link : links) {
String linkHref = link.attr("href");
String linkText = link.text();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With