1

I am trying to scrape data from a website which is on a highchart,I have tried to use class names and it always prints an empty list

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd

driver = webdriver.Chrome('/Users/MR NAT ASS/Downloads/chromedriver')
driver.get("https://www.statsbots.org.bw/motor-vehicle-accident-trend-transport-sector")
data = driver.find_elements_by_xpath('//g[@class="html not-front not-logged-in no-sidebars page-node 
page-node- page-node-105 node-type-easychart mean-container"]')

year_stats = []
for p in range(len(data)):
year_stats.append(data[p].text)

years = driver.find_elements_by_xpath('//g[@class="highcharts-axis-labels highcharts-xaxis-labels"]')

year_list = []
for s in range(len(years)):
year_list.append(years[s].text)

print(year_stats)
#####
print(year_list)

Any suggestions please

2

1 Answer 1

1

All charts are stored in global variable Highcharts. You can get series data for a specific chart by running the below JS code:

Highcharts.charts[2].userOptions.series[0].data;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.