I need to get info from HTML table , java -


i'm trying create program read table in specific website , can data need. read jsoup , elements , tried implement read missing me table html code is

<tr>  <td valign="top" width="980px;">  <!-- start warranty results 	-->    <!-- start warrantyresultsdetails -->  <table class="ibm-data-table" summary="warranty results" border="0" cellpadding="0" cellspacing="0">  <caption><b>warranty information</b></caption>  <thead>  <tr>  <th scope="col">type</th>  <th scope="col">model</th>  <th scope="col">serial number</th>  </tr>  </thead>  <tbody>  <tr>  <td>8205</td>  <td>e6c</td>  <td>06202et</td>  </tr>  </tbody>  <thead>  <tr>  <th scope="col">warranty status</th>  <th scope="col">expiration date</th>  <th scope="col">location</th>  </tr>  </thead>  <tbody>  <tr>  <td>      out of warranty <img src="//1.www.s81c.com/i/v17/icons/_icons/ibm_icon_blue_close.png" alt="" align="middle" height="16" width="16">    </td>  <td>2015-12-26</td>  <td>israel</td>  </tr>  <tr>  <td colspan="3">  <b>warranty description</b>  <br>  product has 3 year limited warranty , entitled cru (customer replaceable unit) , on-site labor repair service selected parts.  on-site service available monday - friday, except holidays, next business day response objective.  service technician scheduled arrive @ customer's location on business day after remote problem determination.  </td>  </tr>  </tbody>    <thead>  <tr>  <th scope="col" colspan="3">additional agreement</th>  </tr>  </thead>  <tbody>  <tr>  <td colspan="3">  <b>  web site provides standard warranty or eservicepac information, please consult local ibm representative or reseller other maintenance services or warranty information specific ibm machine.  </b>  </td>  </tr>  </tbody>    </table>  <!-- end warrantyresultsdetails -->    <!-- end parts -->  </td>  </tr>

i tried use code written here in stackover couldn't modify correct

import org.jsoup.jsoup;  import org.jsoup.nodes.document;  import org.jsoup.nodes.element;  import org.jsoup.select.elements;    public class test {        public static void main(string[] args) throws exception {          string url = "https://www-947.ibm.com/support/entry/portal/wlup?type=8205&serial=06202et";          document document = jsoup.connect(url).get();            string question = document.select("#ibm-data-table").text();          system.out.println("question: " + question);            elements answerers = document.select("#answers .user-details a");          (element answerer : answerers) {              system.out.println("answerer: " + answerer.text());          }      }  }

and here code gives me data still want specific ones table , not of them

import java.io.ioexception;  import org.jsoup.jsoup;  import org.jsoup.nodes.document;  import org.jsoup.nodes.element;  import org.jsoup.select.elements;    public class tableeg {     public static void main(string[] args) {        string html = "https://www-947.ibm.com/support/entry/portal/wlup?type=8205&serial=06202et";                      try {           document doc = jsoup.connect(html).get();           elements tableelements = doc.select("table");             elements tableheadereles = tableelements.select("thead tr th");           system.out.println("headers");           (int = 0; < tableheadereles.size(); i++) {              system.out.println(tableheadereles.get(i).text());           }           system.out.println();             elements tablerowelements = tableelements.select("tr");             (int = 0; < tablerowelements.size(); i++) {              element row = tablerowelements.get(i);              system.out.println("row");              elements rowitems = row.select("td");              (int j = 0; j < rowitems.size(); j++) {                 system.out.println(rowitems.get(j).text());              }              system.out.println();           }          } catch (ioexception e) {           e.printstacktrace();        }     }  }

not java dev really, here goes...

in final loop, have 'rowitems', list of td elements on screen - need way reliably search data bits of data want. i'm guessing not have control on these tables, can't set id on td's you're tracking can search id.

if format stays same, figure out how pull items in 'rowitems' index. index should same data whenever return. that'll point in right direction!


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo