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
Code:
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 = doc.select(“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 = “http://www.ebay.com/s/phone/apple”;
List<String> links = main.extractLinks(site);
for (String link : links) { System.out.println(link); }
}
}