dqcd84732 2013-12-03 14:54
浏览 122

使用preg_match_all和curl来捕获字段的值

I am trying to do an automatic post using curl, but the problem is that there is a hidden field that changes its value every time the page is loaded. So I used preg_match_all to capture this value and pass it to the post. The fact is preg_match_all is not returning anything.

This is the piece of code I'm using:

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL,'http://www.blidoo.es/pub/');
  curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
  curl_setopt($ch,CURLOPT_HTTPHEADER,array("Accept-Language: es-es,en"));
  curl_setopt($ch,CURLOPT_HEADER,false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
  curl_setopt($ch,CURLOPT_PROXYTYPE,'HTTP');
  curl_setopt($ch,CURLOPT_PROXYPORT,'5677');
  curl_setopt($ch,CURLOPT_PROXY,'192.168.11.16');
  curl_setopt($ch,CURLOPT_PROXYUSERPWD,'daemon@AgentOrange.1989');


  $result = curl_exec($ch);
  $rerror = curl_error($ch);
  curl_close($ch);

  preg_match_all("(<input type=\"hidden\" name=\"publicar[_csrf_token]\" value=\"(.*)\" id=\"publicar__csrf_token\" />)siU",$result,$matches1);
  $return = trim($matches1[1][0]);

I have checked the $result and the string is there. What am I doing wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号