I want to scrape the x and y axis of a highcharts graph. As shown here:
https://www.highcharts.com/demo/line-basic
I´m using html_requests
which uses pypeteer to send JavaScript.
chart = r.get("a.com")
script= """return Highcharts.charts[0].series[0].data.map(d=>d.y);"""
chart.html.render(script=script, reload=False)
Now this code results in the following error:
pyppeteer.errors.ElementHandleError: Evaluation failed: SyntaxError: Unexpected token return
I tried another variation of the code:
script='''values = [];
Highcharts.charts[0].series[0].data.forEach((d) => values.push(d.y));
return values;'''
which results in:
pyppeteer.errors.ElementHandleError: Evaluation failed: SyntaxError: Unexpected token return ;
Can someone explain what is happening? Is the response the problem or the JS code itself?