Java Jsoup fetch href link
Fetch href links from HTML file
HTML file
<tr>
<td ><a href='html/f1.html'><div style='text-align:center;'> dog </div></a></td>
<td ><a href='html/f2.html'><div style='text-align:center;'> cat </div></a></td>
</tr>
Java Jsoup Code
// $j/JsoupTry1.java
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public void test0(){
try{
String url = "https://xfido.com";
Document doc = Jsoup.connect(url).userAgent("Mozilla").get();
Elements links = doc.select("a[href]");
for(Element e : links){
pl("text=" + e.text());
pl("toString=" + e.toString());
pl("href=" + e.attr("abs:href"));
}
}catch (IOException e){
e.printStackTrace();
}
}