0

I have written the below code . I need to extract the price from the below URL .I am writing code in java. http://www.walmart.com/ip/VIZIO-E70-C3-70-1080p-240Hz-Class-LED-Smart-HDTV/43310251

String regEx = "<span\\s+class=\"sup\">.+</span>[\n]*(\\d+(,)*\\d+)[\n*]<span\\s+class=\"visuallyhidden\">[.]*</span>[\n]*<span\\s+class=\"sup\">(\\d+)";
Pattern p1 = Pattern.compile(regEx);
System.out.println("Vikash");
while ((line = in .readLine()) != null) {
    sb.append(line + "\n");

}
m = p1.matcher(sb);
while (!m.hitEnd()) {
    if (m.find()) {
        System.out.println("$" + m.group());
    }
}
singhakash
  • 7,891
  • 6
  • 31
  • 65

1 Answers1

0

If you can't use API's, you should use a framework for this. Take a look at http://jsoup.org

It will generate a strucutred document and allows you to iterate over ids, classes, tags and so on.

E.g.

findElementsByClass("sup"). I can provide some examplecode when I'm back at my desktop.

Lama
  • 2,886
  • 6
  • 43
  • 59
  • The pattern that i am seeing in the HTML page is below . It will be better if u use this as an example . I need to extract the price .
    $ 1,398 . 00
    – Vikash Mishra May 05 '15 at 08:24