Inside my Android app I want to receive some table data from an external website.
Lets say website page X has this table inside it's HTML:
<table summary="Foo" border="0" bgcolor="#ffffff" cellpadding="0"> </table>
How would I receive the strings inside all the cells of the second column of the table (top to bottom)?
So far what I have done is the following:
I used the following code inside my AsyncTask:
ArrayList<String> list = new ArrayList<String>(); //table data
Document document = Jsoup.connect(url).get();
Elements nextTurns = document.select(":contains(Foo) td:eq(1)");
for (Element nextTurn : nextTurns) {
list.add(nextTurn.text());
}
When running the code it just seems to stop at the document.select
statement and the GC is going crazy. After a very long time it does get past the document.select
statement and it does get most of the data correct but it still has random other elements from the website.
I am pretty sure this is completely wrong:
Elements nextTurns = document.select(":contains(Foo) td:eq(1)");
But I am unsure how to fix it because the table also lacks any ID's. And I find this page confusing.
How can I fix the select statement and/or for loop so it fills up the ArrayList with data from the second table column?
Edit: by removing contains(Foo)
it's now really fast so that's 1 problem less. I still need help with traversing the DOM elements to the second column of the table without taking a bunch of random parts of the website.