I'm trying to get data from a view-source page: link
which are shown in a table html rows and columns
<div class="table-responsive table-rounded" id="general_imei_info">
<table class="table table-featured">
<tbody>
<tr><td>Model:</td><td>X Power</td></tr>
<tr><td>Brand:</td><td>LG</td></tr>
<tr><td>IMEI:</td><td>TAC: 358937 FAC: 07 SNR: 230126 CD: 1</td></tr>
</tbody>
</table>
In this case I want to obtain the model, Brand and the imei for it I am using the jsoup library for this I have a class called consultation
public class Consulta {
public ArrayList getDatos(String url){
ArrayList <String> list=new ArrayList<String>();
int cont=0;
try {
Document doc=Jsoup.connect(url).get();
Elements table=doc.select("td");
for(Element td:table){
cont++;
if(cont==2 || cont==4|| cont==6)list.add(td.text());
}
} catch (Exception e) {
}
return list;
}
}
the button to consult to show the data a textarea
tout.setText("");
Consulta re=new Consulta();
String imei=txtimei.getText().trim();
ArrayList<String>list=re.getDatos("https://www.imei.info/?imei=358937072301261");
for(int i=0; i<list.size(); i++){
tout.append("Modelo :"+list.get(0)+"\n");
tout.append("Marca :"+list.get(1)+"\n");
tout.append("Imei :"+list.get(2)+"\n");
}
txtimei.setText("");
I already appreciate your time