PHP:curl获取隐藏输入的值

时间:2018-05-29 22:15:21

标签: php curl php-curl

如何获得卷曲响应中隐藏输入的值

<input type="hidden" name="csrf_token" value="b93779b0fd991381de4b67d60a2c4cd948ad1dc9" />

我试过这个

  $rets = curl_exec($ch);
if (preg_match("/csrf_token/", $rets, $spoof)){
 print_r($spoof);
 // here it found it but can't get the value
}

我试过这个

 if(preg_match("/name=\"csrf_token\" value='([a-zA-z0-9]{32})'/", $rets, $spoof)) 

  //empty respown

    {

那么我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

我认为你几乎拥有它,但你的例子中的值是在双引号之间,你的正则表达式期望它用单引号。 试试这个:

if (preg_match("/name=\"csrf_token\" value=\"([a-zA-z0-9]{32})\"/", $rets, $spoof)) 
相关问题