How do I extract a javascript variable from a .js file with python? : <p>I'm trying to extract the JSON data in the variable chartData. This is stored in a .js file which generates a chart for my solar system. I want to extract this data so i can store it in a separate database.</p>

<p>However I cant seem to find a way how to extract the JSON data with python.</p>

<p>This is the .js file.</p>

<pre><code>var chartData =
{
"labels":
[
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"],
"datasets":
[
{
"strokeColor":" rgba(64,178,83,1.0)",
"fillColor":" rgba(64,178,83,.5)",
"data": [
15.101000,9.819000,9.966000,19.634000,18.403000,17.015000,20.356000,20.645000,5.443000,14.542000,13.513000,9.774000,15.053000,16.870000,10.582000,
15.139000,7.230000,9.019000,18.687000,16.074000,17.183000,23.353000,22.248000,22.762000,22.458000,20.809000,18.034000,12.810000,15.627000,21.057000,
19.589000]
}
]
}
var max = 25;
var steps = 5;
var input = document.getElementById("inputId");
input.setAttribute("min",   "2019-02");
input.setAttribute("max",   "2020-01");
input.setAttribute("value", "2019-08");
document.getElementById("labelValueId").innerHTML = " 498.812kWh 08.2019";
document.getElementById("buttonPrevId").disabled  = false;
document.getElementById("buttonNextId").disabled  = false;
var myBar = new Chart(document.getElementById("canvasId")
.getContext("2d"))
.Bar(chartData,
{
"pointDot": false,
"datasetFill": false,
"scaleOverride": true,
"scaleLabel": "&lt;%=value%&gt; kWh",
"scaleSteps": steps,
"scaleStartValue": 0,
"scaleStepWidth": Math.ceil(max / steps),
"scaleLineColor":" rgba(170,170,170,1.0)",
"scaleFontColor":" rgba(170,170,170,1.0)",
"scaleGridLineColor":" rgba(68,68,68,1.0)"});
</code></pre>
