我尝试使用curl发布到此网站,我甚至没有让页面出现..这些字段并不像拥有名称和值一样直接并且表格有一个提交。每次重新加载页面时,表单的地址和操作似乎也会发生变化,因此在" e"之后的数字也会发生变化。在地址中每次增加1 ..
$url = "http://www.canadapost.ca/cpotools/apps/track/personal/findByRefNumber?execution=e14s1"
$parms = array(
'tapByTrackSearch:refSearch:refNumbers' => $refnumber,
'tapByTrackSearch:refSearch:ref_submit_button' => '',
'tapByTrackSearch:refSearch_SUBMIT' => 1,
'javax.faces.ViewState' => 'v1Dxx9hSieZwMVPzZZHAPSkIfrSZM1jbO4mNTTN2U0GpxoAFjzFhwFOL94NDwf6uXDCuuM24L5YMuqNSqP+dRYKpGsqhkV+2Tm+y5O2kdGF/NCNJRzUyCzDzaoELlvqQ/L5LRDJEnbwOXh1YOjylrA==',
);
我稍后循环$ parms数组,并作为$ new_fields字符串传递。
$res = curl_init();
$config =
array(
CURLOPT_URL => $this->url,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $new_fields,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE
);
curl_setopt_array($res,$config);
$result = curl_exec($res);
curl_close($res);
echo $result;
新字段的输出:
tapByTrackSearch:refSearch:refNumbers=#12484&tapByTrackSearch:refSearch:ref_submit_button=&tapByTrackSearch:refSearch_SUBMIT=1&javax.faces.ViewState=v1Dxx9hSieZwMVPzZZHAPSkIfrSZM1jbO4mNTTN2U0GpxoAFjzFhwFOL94NDwf6uXDCuuM24L5YMuqNSqP+dRYKpGsqhkV+2Tm+y5O2kdGF/NCNJRzUyCzDzaoELlvqQ/L5LRDJEnbwOXh1YOjylrA==&
我的代码在其他网站上运行良好,但出于某种原因,我要么输入字段,要么输入错误的值或网址?