I want to find data from a webpage which stores data in Java Script block and later renders the page using those data. How to fetch such data in PHP ?
I've tried DOMXPath and DomDocument, still no luck !
Below I'm posting an example of the target page.
<html>
...
<script type="text/javascript">
var showHeader = true;
var Data = {
"packageId": "120",
"packageTitle": "West Bengal",
"Type": "Customizable",
"Components": [
{
"destination": "Darjeeling",
"dayNum": {
"1": {
"sightseeings": [
"No Sightseeing"
],
"itineraries": {
"title": "Bagdogra / New Jalpaiguri - Darjeeling",
"description": "<p>Welcome to darjeeling.</p>"
}
}
}
}
]
};
</script>
<body>
...
</body>
</html>
I want to retrieve all those data in an associative array using PHP so I can use like $data['showHeader'] or $data['data']['packageId']