Here is the HTML I am attempting to extract MIBLAKD02129
from and write each row of violations. This is the output I need.
12/18/2019 MIBLAKD02129 MI NONE IL TRUCK TRACTOR 3 HOS Compliance Violation: 395.8A-ELD ELD - No record of duty status (ELD Required) (OOS) 5 + 2 (OOS)
Vehicle Maint. Violation: 393.9TS Inoperative turn signal 6
Vehicle Maint. Violation: 393.75(c) Tire-other tread depth less than 2/32 of inch measured in 2 adjacent major tread grooves 8
MY CODE
for rows in insp_tbl.find('tr', {'class' : 'inspection'}):
print(rows)
<td>12/18/2019</td>
<td>
<a class="modalLink"href="/SMS/Event/Inspection/68897149.aspx">MIBLAKD02129</a>
</td>
<td>MI</td>
<td>NONE</td>
<td>IL</td>
<td>TRUCK TRACTOR</td>
<td> </td>
<td>3</td>
for rows in insp_tbl.find('tr', {'class' : 'inspection'}):
for cols in rows.find('td'):
print(cols)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: 'int' object is not iterable
<tr class="inspection">
<td>12/18/2019</td>
<td>
<a class="modalLink" href="/SMS/Event/Inspection/68897149.aspx">MIBLAKD02129</a>
</td>
<td>MI</td>
<td>NONE</td>
<td>IL</td>
<td>TRUCK TRACTOR</td>
<td> </td>
<td>3</td>
</tr>
<tr class="viol oos">
<td colspan="6" class="viol">
<label>HOS Compliance Violation: </label>
<span class="violCodeDesc">395.8A-ELD ELD - No record of duty status (ELD Required)(OOS)</span>
</td>
<td class="weight">5 + 2 (OOS)</td>
<td colspan="1"> </td>
</tr>
<tr class="viol ">
<td colspan="6" class="viol">
<label>Vehicle Maint.Violation: </label>
<span class="violCodeDesc">393.9TS Inoperative turn signal</span>
</td>
<td class="weight">6</td>
<td colspan="1"> </td>
</tr>
<tr class="viol ">
<td colspan="6" class="viol">
<label>Vehicle Maint. Violation: </label>
<span class="violCodeDesc">393.75(c) Tire-other tread depth less than 2/32 of inch measured in 2 adjacent major tread grooves</span>
</td>
<td class="weight">8</td>
<td colspan="1"> </td>
</tr>