I'm trying to fetch Report coronavirus cases table data from https://www.worldometers.info/coronavirus/ to my Android app using Java.
So I have an object called country and instance of the object are countryName, TotalCase, Total death, etc. and then I will store the object in an arrayList.
Here is my code:
import android.os.AsyncTask;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class SammaryHandler extends AsyncTask<Void,Void,Void> {
@Override
protected Void doInBackground(Void... voids) {
try{
Document document= Jsoup.connect("https://www.worldometers.info/coronavirus/").userAgent("mozilla/17.0").get();
// Elements temp= document.select("table table-bordered table-hover main_table_countries dataTable no-footer");
Elements temp= document.select("table.dataTable");//?????????????????
int size= temp.size();
for(int i=0; i<size;i++){
String data= temp.select("table.dataTable").eq(i).attr("");//?????????????
System.out.println(data);
}
}catch (Exception e){
System.out.println(e);
}
return null;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
@Override
protected void onCancelled() {
super.onCancelled();
}
}
So how can I read all of the data from the table and save load in the object?
