-3

I need to do a web scraping on a HTML page with a table with multiple table headers

E.g.:

<table class="tabledata">
  <th colspan="32"> TH1 </th>
  <tr>
    <td>TD11</td>
    <td>TD12</td>
    <td>TD13</td>
    ... ...
    <td>TD1N</td>
  </tr>
  <tr>
    <td>TD21</td>
    <td>TD22</td>
    <td>TD23</td>
    ... ...
    <td>TD2N</td>
  </tr>
  ... ...
  <th colspan="32"> TH2 </th>
  <tr>
    <td>TDfsf1</td>
    <td>TDasf2</td>
    <td>TDads33</td>
    ... ...
    <td>TDcvvN</td>
  </tr>
  <tr>
    <td>TDafadf1</td>
    <td>TDujjj2</td>
    <td>TDnbnbn3</td>
    ... ...
    <td>TDppppaN</td>
  </tr>
  ... ...
  <th colspan="32"> TH3 </th>
  <tr>
    <td>TDfsf1</td>
    <td>TDasf2</td>
    <td>TDads33</td>
    ... ...
    <td>TDcvvN</td>
  </tr>
  <tr>
    <td>TDafadf1</td>
    <td>TDujjj2</td>
    <td>TDnbnbn3</td>
    ... ...
    <td>TDppppaN</td>
  </tr>
  ... ...
  <th colspan="32"> TH12 </th>
  ... ...
</table>

This table has multiple elements. Between elements, there are sibling elements. I would like to get all sibling elements under each element.

EDIT: The HTML is just what it is. Having multiple in the table could be wrong. But this is out of my control. One has multiple s below it then another comes below the then another set of s follow.

alextc
  • 2,317
  • 7
  • 44
  • 80

1 Answers1

-1

Your HTML Markup is wrong, please make sure you are writting valid HTML.

You can find elements by using jQuery like:

$('.tabledata').find('td');
Willie Cheng
  • 5,589
  • 7
  • 39
  • 58