Using Php how to get Javascript Object Value

121 views Asked by At

its javascript code from another website var images = { article_id : '1111', channel : '$11111', image_license : 'https://website.com/test', name : 'numbers" }

Using Php how to get the value of the image _license ( https://website.com/test )

the idea is i made a article grabber , it work get title,description,etcs from html , but i cant get this value from js code , so what to do it ?

1

There are 1 answers

1
Illya On BEST ANSWER

try to use regular expression:

preg_match("/image_license\s*:\s*'(.*?)'/",$html,$result);
$image_license_url = $result[1];

another example :

preg_match("/var images = (\{.*?\})/",$html,$result);
$images_array = json_decode($result[1]);

Reference : https://www.php.net/manual/en/function.preg-match.php