V
V
vitya192020-05-30 20:38:27
PHP
vitya19, 2020-05-30 20:38:27

json php not parsing?

I am writing a parser for insta, and such a problem, the information on the page is in the script and looks like this

<script type="text/javascript">
 window._sharedData = {};
</script>

So, with the help of regular expressions in php, I get all the json part, but when I try to pass it to json_decode(); she returns emptiness
preg_match( '/window\._sharedData\s=\s(?<data>.*?)\;\<\//m', $result, $mat);
json_decode( $mat['data'] );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
ninja op op, 2020-05-30
@vitya19

tryjson_decode( $mat['data'], true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question