Tuesday, 20 June 2017

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 = 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); }



No comments:

Post a comment

All about journals and research paper | What is impact factor? | how the impact factor is calculated? | who calculate the impact factor? Scopous journals

Figure 1: One of my Research Papers When the Scholars are in their Master or PhD or in any research field. They are supposed to writ...