从Python Selenium中具有相同类名的所有div中获取所有文本



我想从Bet365获得今天所有的大型游戏(警告这是一个赌博网站!(但我只能获得第一个游戏。

我尝试了这个,但没有工作:

try:
driver.maximize_window()
driver.get("https://www.bet365.es/#/HO/")
driver.implicitly_wait(5)
except:
print("No se ha podido acceder a Bet365. Comprueba si la página funciona correctamente y no estas bloqueado de ella.")
try:
partidos_destacados = driver.find_element_by_class_name("fh-ParticipantFixtureTeam_TruncateName")
for i in partidos_destacados:
print(i.text)
except:
print("No se han podido leer los partidos destacados. Comprueba si ha cambiado el nombre del class en el HTML de BET365")

存在许多类名为"的div;fh-ParticipantFixtureTeam_TruncateName;我需要得到所有这些。

我遇到了错误。我使用的是driver.find_element_by_class_name,但我需要使用driver.find_elements_by_class_name.

这是固定的代码:

try:
driver.maximize_window()
driver.get("https://www.bet365.es/#/HO/")
driver.implicitly_wait(5)
except:
print("No se ha podido acceder a Bet365. Comprueba si la página funciona correctamente y no estas bloqueado de ella.")
try:
partidos_destacados = driver.find_elements_by_class_name("fh-ParticipantFixtureTeam_TruncateName")
for i in partidos_destacados:
print(i.text)
except:
print("No se han podido leer los partidos destacados. Comprueba si ha cambiado el nombre del class en el HTML de BET365")

最新更新