0

I was wondering whether if there was a simple means of converting scraped Highcharts series data into Python dictionary data with a certain software package.

I've referred to this helpful previous question here about scraping Highcharts plots (Can I scrape the raw data from highcharts.js?). However, I've been unable to actually replicate the ability to parse the scripts with js2xml. Having already been able to target the series data I'm looking for with regular expressions, I figured it may be easier to directly convert that Highcharts series data into a Python dictionary.

This is the text structure of the Highcharts series data after I've scraped it:

series: [{
                type: 'area',
                name: 'Likes',
                data: [
[Date.UTC(2018, 05-1, 22), 27420 ],
[Date.UTC(2018, 05-1, 23), 27423 ],
[Date.UTC(2018, 05-1, 24), 27424 ],
[Date.UTC(2018, 05-1, 25), 27427 ],
]
}]

Consequently, I was wondering whether a software package already exists that allows me to easily convert Highcharts series data into a Python data type. After a couple hours of Googling, I found a few examples of software packages allowing easy transition of Python dictionary to Highcharts series, but was unable to find a package that easily let me go the other way. If no simple solution exists, I'll just continue using regular expressions to iterate line-by-line through each series text and capture the numbers. Thanks for the help.

potpie
  • 91
  • 1
  • 8
  • @SacredGeometry, thanks for the tip. I don't have access to the original data itself prior to Highcharts form, as it seems to be obfuscated on the website that I'm getting the info from. Do Highchart series easily convert into a JS format? Not very familiar with JS. If not, I think best bet will be the more tedious way of isolating the dates and numbers with regexp in Python, and then re-creating data frame from there. – potpie Jun 23 '19 at 21:35
  • Hi @potpie, Could you provide us with an example of a page from which you want to get data? – ppotaczek Jun 24 '19 at 18:23
  • @ppotaczek try https://www.investsmart.com.au/invest-with-us/investsmart-growth-portfolio – flywire Apr 05 '21 at 06:33
  • Hi @flywire, You can get the data by calling this script: `Highcharts.charts[x].userOptions.series` – ppotaczek Apr 06 '21 at 08:12
  • @ppotaczek I'm only a user and been getting dead ends. Could you demonstrate that in an answer? (It's a very simple chart, ignore creating it from the svg with a linear equation.) – flywire Apr 06 '21 at 12:51
  • You just need to open a browser console and type the above script. For example: `Highcharts.charts[0].userOptions.series[0].data` – ppotaczek Apr 07 '21 at 08:43

0 Answers0