so basically i am searching for class “dark” , but i am getting all the classes which have “data” + extra_text , like “dark hide-for-mobile”,”dark bold” are also showing up in my results
this is what the data or tbody looks like
enter image description here
now i want to get data in the class=”dark” element , so for first driver it should be 1 , then 2 for 2nd driver all the way to 20 or dnf
this is the code i am using to get the driver position
def get_driver_position(tbody):
list_of_driver_positions = []
tds = tbody.find_all("td", class_="dark")
for td in tds:
pos = td.get_text()
if not pos:
continue
else :
list_of_driver_positions.append(pos)
print(list_of_driver_positions)
return list_of_driver_positions
now i hope to get something like
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
but i am getting
['1', '1', 'nMaxnVerstappennVERn', '1:20:43.273', '2', '11', 'nSergionPereznPERn', '+13.643s', '3', '16', 'nCharlesnLeclercnLECn', '+18.639s', '4', '81', 'nOscarnPiastrinPIAn', '+32.007s']
Sarthak Ahuja is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.