I have a simple HTML file that contains data I'm trying to scrape out so that I can work with the variables.
<html>
<head>
<link rel="stylesheet" type="text/css" href="/app/css/style.css" />
</head>
<body>
<div class="page">
<div class ="pane">
<div class ="chart">
<h1 style='float: left;'>Summary</h1>
<div style='clear: both;'></div>
<script type="text/javascript" src="protovis/protovis-d3.2.js"></script>
<script type="text/javascript+protovis">var data = [
{"label":"A (2)", 'complete': 2.0, 'pending': 0.0}
,{"label":" B (8)", 'complete': 8, 'pending': 0.0}
,{"label":"C (10)", 'complete': 10, 'pending': 0.0}
,{"label":"D (18)", 'complete': 18.0, 'pending': 0.0}
,{"label":"E (21)", 'complete': 21, 'pending': 0.0}
];
</script>
</div>
</div>
</div>
</body>
</html>
Using PHP, I'm trying to parse the the data contained on this HTML in to variables. I.E.: $A = 2
, $B = 8
, $C = 10
, $D = 18
, $E = 21
.
So far, I've been trying to use the simple_html_dom.php library to read the data, but I haven't been able to retrieve the contents of the JSON contained within the JavaScript above.
How can I pull "label":"A (2)"
out of the HTML above so that I can access the value (in this case 2) as a PHP variable?