I am on this page:
https://fantasy.premierleague.com/statistics
When you click on any "i" icon next to a player, a popup window appears. Then, i want to get the surname of the player. This is how "inspect element" looks like ("whitespace" actually appears within a box):
<h2 class="ElementDialog__ElementHeading-gmefnd-2 ijAScJ">
Kevin
whitespace
De Bruyne
What i want to do is to take the text that appears after the whitespace. I can get the full text (ie both name and surname) using this:
player_full_name = driver.find_element_by_xpath('//*[@class="ElementDialog__ElementHeading-gmefnd-2 ijAScJ"]').text
but how can i get the surname only (ie what appears after the whitespace)? Note that for other players it could have been like this:
<h2 class="ElementDialog__ElementHeading-gmefnd-2 ijAScJ">
Gabriel Fernando
whitespace
de Jesus
or like this:
<h2 class="ElementDialog__ElementHeading-gmefnd-2 ijAScJ">
Dean
whitespace
Henderson
ie splitting the text and taking the last one or two elements will not work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…