Pedro
Pedro

Reputation: 1

Extracting data using JSoup

I am trying to extract product name information from Google Shopping (http://www.google.co.uk/m/products?q=5010459007289, phone website).

The product name always appear in between the span with class "owb63p",for example

"<span class="owb63p">Highland Spring Sports Bottle 750 Ml</span>"

I am new with JSoup, I can connect with the URL and get the whole document, but I just need help setting it up so that I only get the piece of information I need.

Upvotes: 0

Views: 488

Answers (4)

simplysiby
simplysiby

Reputation: 584

You could try

doc.select("span").get(0).data();

or you can simply iterate for multiple span tags...

Upvotes: 0

vacuum
vacuum

Reputation: 2273

In JSoup it will be like:

Document doc = Jsoup.connect("www.google.co.uk/m/products?q=5010459007289").get();
Element title = doc.select("span.owb63p").first();
    System.out.println(title.text());

Upvotes: 1

user824181
user824181

Reputation:

It looks like JSoup examples has what you are looking for.

Upvotes: 0

Snicolas
Snicolas

Reputation: 38168

I don't like JSoup that much, but with apache jericho it would like :

            Source source=new Source(new URL(sourceUrlString));
    String content=source.getFirstElementByClass( "owb63p" ).getContent().toString();

Upvotes: 0

Related Questions