I have the following issue:
I have this HTML Code:
<tr class="_requirement odd">
<td class="_unit">XXX <strong>9999</strong></td>
<td class="_time">07:30 - 18:00</td>
<td><span class='_photo' data-id='1234567'>Franz Wundschuh</span>, <span class='_photo' data-id='98765432'>Dieter Bohlen</span>
</td>
<td class="_location">Stall<br /></td>
</tr>
<tr class="_requirement even">
<td class="_unit">YYY<strong>8888</strong></td>
<td class="_time">08:00 - 18:00</td>
<td><span class='_photo' data-id='3641'>Julia Schwarz</span>
</td>
<td class="_location">Haus<br /></td>
</tr>
<tr class="even">
<td class="_note" colspan="4">Information</td>
</tr>
Now the following task:
I want to store the information in a database. I need from the <tr>
with class="_requirement odd"
the information "XXX" in the first column, "9999" in the second column, in this case the 3rd column is empty.
Further I need from the <tr>`` with
class="_requirement even"the information "YYY" in the first column, "8888" in the second column and in the 3rd column from the
`` "information".
That means, whenever after a class="_requirement even"
a <tr class="even">`` comes in the third column the value from the
in it (In this case "Information". The same - if after a ```class="_requirement odd"``` comes a ```<tr class="odd">
in the third column the value from the <td>
in it (In this case "Information".
If no "odd" or "even" comes after the requirements odd or even, the third column should be empty.
I can't get it together.
The following code for the first 2 columns I already have:
for shift in driver.find_elements(By.TAG_NAME, 'tr'):
shiftLine = []
for field in shift.find_elements(By.TAG_NAME, 'td'):
tdClass = field.get_attribute('class')
if tdClass == '_unit':
splitUnit = field.text.split()
shiftLine.append(splitUnit[0])
if len(splitUnit) == 2:
shiftLine.append(splitUnit[1])
else:
shiftLine.append('')
Aucun commentaire:
Enregistrer un commentaire