Kelvin Ding
Kelvin Ding

Reputation: 115

Using JSOUP to get values from websites

I have been trying to get the winning numbers from Singapore Pools Lottery. This is my code:

public class getlatestWinningNumberAsyncTask extends AsyncTask<String, Void, String> {

        Document doc2 = null;
        Elements TestEle = null;

        @Override
        protected String doInBackground(String... params) {
            try {
                doc2 = Jsoup.connect("http://www.singaporepools.com.sg/en/toto/Pages/results.aspx").get();
                TestEle = doc2.select("table.table-striped");

                Log.e("TestEle", String.valueOf(TestEle));
            } catch (IOException e) {
                e.printStackTrace();
            }


            return null;
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
        }
    }

How do I achieve it?

Upvotes: 1

Views: 99

Answers (1)

luksch
luksch

Reputation: 11712

It seems that the old drawings are loaded via an AJAX call. I looked at the network trafffic and it appears that this URL is called:

http://www.singaporepools.com.sg/DataFileArchive/Lottery/Output/toto_result_top_draws_en.html?v=2015y8m18d14h30m

the v parameter seems to give the date and time of the drawling. If you want to use Jsoup, then you should figure out the v parameter correctly and call teh above mentioned URL with Jsoup.

Upvotes: 1

Related Questions