I am trying crawl values from td in a website using jsoup. I am new to jsoup so please tell me how to do it. Also the td or tr has no class or id to get values from so please help me on it. The html is as follows,
<table cellpadding="4" id="ctl00" style="color:#333333;width:100%;">
<tbody>
<tr align="center" style="color:White;background-color:#990000;">
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
<tr align="center" style="color:#333333;background-color:#F7F6F3;">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
I need the output as 1 2 3 4 5 6 please help me to get this.
You can get the required page by connecting the URL. once you have the document then look for elemnt 'td'(check the document by printing it to console if the text is in upper/lower based on that you need to use TD/td). Then get the text.
Document document = Jsoup.connect("http://www.google.com").get();
Element table = document.getElementById("tableId");
Elements tds = table.getElementsByTag("td");
for(Element td : tds)
{
System.out.println(td.text());
}