Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pretorh/200483dec3f0b85ae9d06b3471d2c2e7 to your computer and use it in GitHub Desktop.
Save pretorh/200483dec3f0b85ae9d06b3471d2c2e7 to your computer and use it in GitHub Desktop.

Find the table / table body, and get the rows: $('tbody').children('tr')

For a specific row (ex 12th), find the cells (tds): .eq(11).children('td')

For all the cells, skip those that have an attribute: not('td[rowspan=8]')

Skip over some fixed columns (ex start at column 2): slice(1, 31)

For example on http://www.tshwane.gov.za/sites/Departments/Public-works-and-infrastructure/Pages/Load-Shedding.aspx, to get

  • the schedule
    • the 10th tbody
  • for stage 4 (4th in each group) at "3:00 to 5:30" (2nd group)
    • groups of 8, so 8 * (2 - 1) + 4th
    • 3 "header" rows
  • on day 6 (6th column):
    • skipping the rowspan columns (rowspan attr) and the "stage x" columns (slice)
$('tbody').eq(10 - 1)
  .children('tr').eq(3 + (8 * (2 - 1)) + (4 - 1))
  .children('td').not('td[rowspan=8]').slice(1, 31)
  .eq(6 - 1).text().trim()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment