Answer the question
In order to leave comments, you need to log in
How to find the desired element in string?
Get the content of the desired page:
$context = stream_context_create(array("http"=>array(
"method" => "GET",
"header" => "Accept: text/*, */*\r\n",
"ignore_errors" => true,
)));
$page = file_get_contents("https://instagram.com/accounts/login/", false, $context);
$content = preg_match('<input type="hidden" name="csrfmiddlewaretoken" value="(.*?)">', $page, $found);
Answer the question
In order to leave comments, you need to log in
It's better not to parse HTML with regular expressions .
It is much more convenient to get the desired input using a CSS selector. Take the appropriate library from TJ or Symfony .
preg_math() returns 1 or 0 , it does not return what it found... But the name of the variable "$content" for some reason tells me that you are checking it.
Check the $found variable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question