Site icon NgDeveloper

Parsing Flipkart using Java

Hi webscrappers,
Herewith I have given the example working java code to parse flipkart and take the price of the given book (isbn).

I have used Jsoup library. you can download from here,
Jar Download:
Jsoup Jar

Java Program:
[java]
package in.javadomain;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class FlipkartBookPrice {
public static void main(String[] args) throws IOException {
String bookIsbn = "9780070264984";
String fkPrice = getFlipkartPrice(bookIsbn);
System.out.println("Flipkart Price of " + bookIsbn + ": \n" + fkPrice);
}

private static String getFlipkartPrice(String bookIsbnNo)
throws IOException {
String baseUrl = "http://www.flipkart.com/search-book?q=" + bookIsbnNo
+ "";
String fkPrice = null;
Document doc = Jsoup.connect(baseUrl).timeout(0).get();
fkPrice = doc.select("span.fk-font-verybig").select("span.pprice")
.select("span.fk-bold").text();
return fkPrice;
}
}
[/java]

Output:
Flipkart Price of 9780070264984:
Rs. 436

Exit mobile version