我想從this page檢索表單。我設置了cookie併發送了表單數據,但是我返回的是無效頁面。php捲曲試圖檢索頁面,但不工作
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init ("http://services.www.gov.qa/TV/process/TV/TV_TrafficViolation?lang=en¬loggedin=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);
的「此頁」鏈接似乎去到一個交易不成功的頁面。另外,我試着把你的代碼封裝在php標籤中並打開它,它肯定會從那裏返回一些東西,它只是一個由Web服務器發送的錯誤頁面。但是,它確實包含很多相對於其他頁面的鏈接,並且它們的服務器上的代碼沒有在本地解析。 –
你必須從這個頁面開始:http://services.www.gov.qa/TV/process/TV/TV_TrafficViolation?lang = en&notloggedin = true,然後點擊按板號搜索。 – user1936504