PHP:如何通过php从aspx表单post方法中抓取数据

时间:2014-01-10 05:56:30

标签: php

我有一个aspx页here。该页面包含一个包含帖子操作的表单:

<form name="form1" method="post" action="Average1_web.aspx" id="form1">

提交表单后的结果本身就是一个aspx页面(Report_For_mthly_avg_Zonewise.aspx)。

我需要从结果页面中抓取表格输入的所有排列和组合的数据。有什么方法可以在php字符串而不是在页面(Report_For_mthly_avg_Zonewise.aspx)中获得post方法的结果吗?

由于

1 个答案:

答案 0 :(得分:1)

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, "yourform.php"); 
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, array('field1' => 'val1','field2' => 'val2','field3' => 'val3','field4' => 'val4'));
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

  $result = curl_exec($ch);
  echo $result;

$ result将保留表单在提交后登陆的页面的html代码...所以你要抓的页面。