0

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 ?

  • Hi, please read https://stackoverflow.com/help/how-to-ask for information on how to ask a useful question. Please post any code you have tried or error message that you are getting. The links you posted are 404 so it is hard to understand what you are asking. – trashrobber Feb 28 '20 at 13:11
  • Please check if either of these links help you: https://stackoverflow.com/questions/4343596/how-can-i-parse-a-json-file-with-php https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php – trashrobber Feb 28 '20 at 13:13
  • 1
    Does this answer your question? [How do I extract data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php) – trashrobber Feb 28 '20 at 13:14
  • no it wasn't related to my question, anyway it solved with preg_match , thanks for your contribution. – shehabmustafaaa Feb 29 '20 at 18:38

1 Answers1

0

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

Illya
  • 1,268
  • 1
  • 5
  • 16