I am looking to scrape data from this site's mma data and parsing a few highcharts tables. I am clicking a link with selenium and then switching to the chart. I go to this site and click on +420 in the Artem Lobov row for the Pinnacle column. This creates a pop out chart. Then I switch to the active element. I would like to capture the graph drawn by highcharts in response to the click.
I use selenium in the following manner:
actions = ActionChains(driver)
actions.move_to_element(driver.find_element_by_id(pin_id))
actions.click()
actions.perform()
time.sleep(3)
driver.switch_to_active_element()
I was able to click the link and get the chart but I am a bit lost on how highcharts works.
I am trying to parse highcharts-series-group here
and get the values in the chart.
I believe the data can be found by:
soup = bs4.BeautifulSoup(open(driver.page_source), "lxml")
data = soup.find_all('g', {"class":"highcharts-series-group"})[-1].find_all("path")
However this provides the following and it it is not clear how a chart is created from the data. As noted in the comments, it appears to be svg.
During inspection the data appears to be in <g class="highcharts-series"
and <g class="highcharts-series-tracker
but its not clear highcharts graphs it from this data.
How does highcharts display the graph from data saved? Is there a clean way to get the data from the highcharts-series-group as displayed?
Highcharts.charts[index]
, like this:Highcharts.charts[0].series[0].options.data
. I guess Selenium won't allow this. – Paweł Fus