0

我正在尝试从此页面检索表单。我设置了 cookie 并发送了表单数据,但我得到的只是无效页面。

$ckfile = tempnam ("/tmp", "CURLCOOKIE");


$ch = curl_init ("http://services.www.gov.qa/TV/process/TV/TV_TrafficViolation?lang=en&notloggedin=true");
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec ($ch);


$ch = curl_init ("http://services.www.gov.qa/TV/continue/TV/TV_TrafficViolation/2/CPN");
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
    'sopEngineTabRef' => '1376927282615',
    'act' => 'byCarPlateNo',
    'txiVehicleNumber' => '',
    'mnuVehicleType' => 'PRV',
    'vehicleNumberNType' => '12332/PRV',
    'searchCriteria' => '1',
    'searchCriteria' => 'qatariUser1',
    'vehicleNumberAndType' => '12332/PRV',
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo $output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
4

1 回答 1

0

在我看来,一个问题是您返回的页面包含大量 jQuery/js/ajax 内容,您必须解析和解释这些内容——curl 基本上只是显示 html。它还退回物品,例如:

<script type="text/javascript" src="/TV/hukoomi/scripts/hukoomi_combined_js.js"></script>

您的脚本将尝试在当前本地目录中找到哪个,需要使用完整路径重写,即http://services.www.gov.qa/TV/hukoomi/scripts/hukoomi_combined_js.js

于 2013-08-19T19:42:03.430 回答