(May-19-2021, 07:30 AM)euras Wrote: thank you snippsat for your help! But I don't get it how to place that in an actual call for element. How to write that syntax on the following example?As don't now content of
contents
,here is example from other Thread taken step further.I use BS as it's easier to show than Selenium,CSS selector usage would be the same
So generate new selectors to take out first name,so a working example of similar task that you are trying to do.
from bs4 import BeautifulSoup html = '''\ <table style="width:100%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Jill</td> <td>Smith</td> <td>50</td> </tr> <tr> <td>Eve</td> <td>Jackson</td> <td>94</td> </tr> </table>''' soup = BeautifulSoup(html, 'lxml') contents= soup.select('tr') for inda, content in enumerate(contents, 1): print(soup.select_one(f'tr:nth-child({inda}) > td:nth-child(1)').text)
Output:Firstname
Jill
Eve