1
How can I be extracting the value of "csrf_token" from this code on the page:
EDIT: There was one missing }
at the end of string
of variable window._sharedData
, so the json string was invalid.
<script type="text/javascript">window._sharedData = {"activity_counts":null,"config":{"csrf_token":"WrNBfRGzWkUl4tsZsqm1HfwhDUDKNFts","viewer":null},"supports_es6":true,"country_code":"unknown","language_code":"pt-br","locale":"pt_BR","entry_data":{"LoginAndSignupPage":[{"captcha":{"enabled":false,"key":""},"gdpr_required":false,"tos_version":"row","username_hint":""}]},"gatekeepers":{"ld":true,"seo":true,"seoht":true,"sf":true,"saa":true},"knobs":{"acct:ntb":0,"cb":0,"captcha":0}}
I tried this way, but I didn’t succeed:
$data = curl_exec($ch);
$json = json_decode($data, true);
echo $json["config"][0]["csrf_token"];