I'd like to get some data from this web site - to be more precise I'd like to get information about champions' win rate over game length. HTML elements containing this information can be found inside 'tspan' elements - but strangely enough some 'tspan' elements are scraped by my code whereas others are not
the website: https://www.op.gg/champions/cassiopeia/mid/trends?region=global&tier=platinum_plus
exemplary tspan elements from this site:
<text x="60" y="31.440000000000026" class="recharts-text recharts-label" text-anchor="middle" style="fill: rgb(117, 133, 146); font-size: 11px; font-weight: bold;">
<tspan x="60" dy="0em">2nd</tspan>
</text>
<text width="60" height="131" x="39" y="42.75" stroke="none" fill="#666" font-size="11px" color="#9AA4AF" class="recharts-text recharts-cartesian-axis-tick-value" text-anchor="end">
<tspan x="39" dy="0.355em">54%</tspan>
</text>
Here's my code:
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.op.gg/champions/cassiopeia/mid/trends?region=global&tier=platinum_plus")
results = driver.find_elements(By.TAG_NAME, "tspan");
for r in results:
print(r.text)
OUT:
13.04
13.05
13.06
13.07
13.08
13.09
13.10
13.11
13.12
13.13
50%
51%
52%
53%
54%
13.04
13.05
13.06
13.07
13.08
13.09
13.10
13.11
13.12
13.13
1%
2%
3%
4%
5%
13.04
13.05
13.06
13.07
13.08
13.09
13.10
13.11
13.12
13.13
0%
1%
2%
3%
4%
0
25
30
35
40
48%
50%
52%
54%
56%
As you can see - I get the data about win ratio (eg. 56%) or the game length (eg. 25 min, 30 min etc) but I don't get anything about Cassiopeia's position in comparison to other champions (I'd like to get information that she has the first win ratio if the game lasts 25 minutes, ninth when it lasts 30 minutes and so on) - but although it should be in 'tspan' elements I don't get it. Can someone help me?