Example usage for org.jsoup.select Elements hasClass

List of usage examples for org.jsoup.select Elements hasClass

Introduction

In this page you can find the example usage for org.jsoup.select Elements hasClass.

Prototype

public boolean hasClass(String className) 

Source Link

Document

Determine if any of the matched elements have this class name set in their class attribute.

Usage

From source file:com.dalthed.tucan.scraper.SingleEventScraper.java

/**
 * /*from w w w  .j a  v  a 2  s .  c o m*/
 */
private void scrapeInformations(Iterator<Element> informationIterator) {

    while (informationIterator.hasNext()) {

        Element nextElement = informationIterator.next();

        Elements td = nextElement.select("td");
        if (td != null && td.hasClass("tbdata")) {
            Elements Paragraphs = nextElement.select("p");
            Iterator<Element> PaIt = Paragraphs.iterator();
            ArrayList<String> titles = new ArrayList<String>();
            ArrayList<String> values = new ArrayList<String>();

            while (PaIt.hasNext()) {

                Element next = PaIt.next();
                String[] information = crop(next.html());
                if (information[1].length() > 0) {
                    titles.add(information[0]);
                    values.add(information[1]);
                }

            }
            Log.i(LOG_TAG, "Informationscraper working");
            if (mPageAdapter != null) {
                Log.i(LOG_TAG, "InformationAdapter set");
                mPageAdapter.setAdapter(new TwoLinesAdapter(context, titles, values));
            }
        }
    }
}