How to get web results as web links from any website programatically?


1. Download jsoup lib.

2. Add the downloaded jar file to project and configure the path
see how to perform this

3. Add the following code to the .java class

public class main {
public static List<String>extractLinks(String url) throws Exception

final ArrayList<String> result = new ArrayList<String>(); 
Document doc = Jsoup.connect(url).get();
Elements links =“a[href]”); 
for (Element link : links)
{ result.add(link.attr(“abs:href”)); } return result; }

public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
String site = “”; 
List<String> links = main.extractLinks(site);
for (String link : links) { System.out.println(link); }



Leave a Comment