I am trying to extract data from an SVG chart using selenium. The XPATH seems correct as with an xpath helper wizard I retrieve the value, but running a Python script it returns an empty value...
Here is a part of the code
<svg width="710" height="184">
<g>
<g class="sub _0">
<g>
<circle cla ss="dot xh-highlight" r="0" fill="#3887DD" cx="0" cy="117.55757575757576" style="fill-opacity: 1e-06; stroke-opacity: 1e-06;">
<title class="">Tue Feb 09 2016 01:00:00 GMT+0100 (CET): 120</title>
</circle>
<circle class="dot" r="0" fill="#3887DD" cx="0.8892086330935252" cy="117.34121212121212" style="fill-opacity: 1e-06; stroke-opacity: 1e-0;">
<title class="">Wed Feb 10 2016 01:00:00 GMT+0100 (CET): 138</title>
</circle>
</g>
</g>
</g>
</svg>
and the Selenium code
LaunchDate = driver.find_elements_by_xpath("//*[name()='svg']/*[name()='g']/*[contains(@class ,'_0')]//*[name()='circle'][1]").text
Does anyone Know what goes wrong ?
Thanks
Your html has an error, an extra space in the word class of the first circle.
i this this should work to get the first circle:
//svg//g[contains(@class,"_0")]//circle[contains(@class,"highlight")]
i hope it helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.