【问题标题】:PHP : curl get the value of hidden input by regexPHP:curl通过正则表达式获取隐藏输入的值
【发布时间】:2018-05-29 22:15:20
【问题描述】:

如何获取 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

    {

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

【问题讨论】:

标签: php regex preg-match


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    相关资源
    最近更新 更多