我尝试使用我定义的属性填充该表单并自动执行提交操作后刮取网站。然后,我将刮取结果页面中的数据。
然而,我还没有对这部分进行编码。但是,当我编译它时,正在显示正常的网页http://www.indianrail.gov.in/pnr_Enq.html(我想要提交表单并获取结果页面的网址)。
未显示提交的结果页面。我将这个ruby脚本作为参考https://github.com/alagu/pnrapi-ruby/blob/master/models/status.rb#L15
$ch = curl_init();
$timeout=5;
$name=$_REQUEST['name'];
$pass=$_REQUEST['pass'];
$rand_captcha = '11111';
$data = array('lccp_pnrno1' => '2257870493', 'submitpnr' => 'Get Status', 'lccp_cap_val' => $rand_captcha, 'lccp_capinp_val' => $rand_captcha);
//$data=http_build_query($data);
curl_setopt($ch,CURLOPT_URL,"http://www.indianrail.gov.in/pnr_Enq.html");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
echo $data;
curl_close($ch);
答案 0 :(得分:0)
$curl_connection
应为$ch
。