0

I've been trying to scrape a specific highchart, using console commands, something in the line off:

data = $('div#graphCont2').highcharts().series[0].data; { console.log(data)}

This code works on the following site, I retrieve all data. test-hichart1

However, when I rework the code for the graph I intend to scrape (chart, Its the uppermost chart, APX-PSE for all X and Y entries), I miss data. It varies somehow (based on the timestamps, it seems to vary by the selected period), but I only get data from around timestamp 1562284800000 and onwards when the period is set to "all" (thus missing 2/3 of all entries).

I use this code:

data = $('div#stockchart_apx').highcharts().series[0].data; { console.log(data) }

My idea was to use a console.table to get the info I need, though I'm unsure if the table is usable past 999 entries anyway. Does anyone have an idea of why the readout fluctuates and how I can retrieve all the information?

Thanks!

EDIT~ so, after a couple more hours, I managed to get all data by opening the graph in full-window mode. I'm unsure to where the differences originate from, but it worked. I scraped the data with:

data = $('div#stockchart_apx').highcharts().series[0].data;
const getCircularReplacer1 = () => {
  const seen = new WeakSet();
  return (key, value) => {
    if (typeof value === "object" && value !== null) {
      if (seen.has(value)) {
        return;
      }
      seen.add(value);
    }
    return value;
  };
};

JSON.stringify(data, getCircularReplacer1());
enzo1291
  • 1
  • 1
  • Try this one: `Highcharts.charts[0].series[0].data` – Sebastian Wędzel Jul 07 '20 at 09:13
  • It works equally great! See: ```data = Highcharts.charts[0].series[0].data; const getCircularReplacer2 = () => { const seen = new WeakSet(); return (key, value) => { if (typeof value === "object" && value !== null) { if (seen.has(value)) { return; } seen.add(value); } return value; }; }; JSON.stringify(data, getCircularReplacer2());``` However, the problems with the missing data seem to originate from the selected periods (1m, 3m, 6m, 1y, all). When I select "all", I still only get 6m or 1y (except for a single try). – enzo1291 Jul 07 '20 at 14:22

0 Answers0