<tr class="list even">
<td class="list">5</td>
<td class="list"><s>BI</s>→MU</td>
<td class="list"><s>TEACHER</s>→TEACHER</td>
<td class="list">Hello I am a Text</td>
<td class="list">5b</td>
<td class="list">BI3</td></tr>
This is one of the table rows. There are some with one row as an inline header, but idc for them.
So, I want to only get the rows that contains the string "8f" but not only the td, the whole tr
In case there are multiple rows containing the string it should give me a list from them
for row in soup.find_all('tr', class_='list even'):
if '5b' in row.text:
print(row)
for cell in row.find_all('td'):
if "5b" not in cell.text:
print(cell.text)
for row in soup.find_all('tr', class_='list odd'):
if '5b' in row.text:
for cell in row.find_all('td'):
if "5b" not in cell.text:
print(cell.text)
I have this now, but it adds a newline before the last table field: https://haste.thevillage.chat/foguvakixa.py
if "5b" not in cell.text:
This is because if i request the data for 5d i dont need to know again that its 5d. So this just filters the class itselfs out