K
K
kr_ilya2019-08-22 13:58:09
PHP
kr_ilya, 2019-08-22 13:58:09

How to parse the contents of a script tag in php?

You need to parse data from the page from the script tag. For example:

<script>
    window.runParams = {
        data: {"actionModule": 123}
    }
</script>

In simple html dom, I did not notice such functionality. Tell me how you can do this, so as not to reinvent the wheel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kolesnikov, 2019-08-22
@kr_ilya

<?php
  $str = file_get_contents('http://site.com');
  preg_match_all('#<script>(.+?)</script>#su', $str, $res);
  var_dump($res);
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question