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

2 comments

  • waqar

    hi ,
    can you plz help me , i want to call flipkart api to list adds on my website ho to do it with flipkart affiliation,
    i have created flipkart affiliation account but i dont now how to call it from java spring.

    • Flipkart affiliate is to display their product details in iframe or using scripts. Please be clear on doubts/clarifications to help you better.

Leave a Reply to NaveenCancel reply