作者s890510 (水色星晨)
看板PHP
標題Re: [請益] 怎麼讓curl對aspx網頁?
時間Tue Aug 31 10:49:53 2010
這是目前寫的程式碼...
但問題是每次送出後,沒有辦法到下一個畫面,都是停在原先的進入畫面...
查詢HEADER也看不出有cookie的痕跡...
應該要跳到的畫面:
http://ppt.cc/A8UP
--code--
<?
$link = "
http://eschool.firstbank.com.tw/member/index.aspx";
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 13);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
$result_validation = $result_state = curl_exec ($ch);
$token = "__VIEWSTATE";
$result_state = strstr($result_state, $token);
$result_state = substr($result_state, strlen($token));
$endpos = strpos($result_state, '" />');
$result_state = substr($result_state, 26,$endpos-26);
$token = "__EVENTVALIDATION";
$result_validation = strstr($result_validation, $token);
$result_validation = substr($result_validation, strlen($token));
$endpos = strpos($result_validation, '" />');
$result_validation = substr($result_validation, 32,$endpos-32);
$fields = array('__EVENTTARGET' => 'selectCompany',
'__EVENTARGUMENT' => '',
'__LASTFOCUS' => '',
'__VIEWSTATE' => $result_state,
'__EVENTVALIDATION' => $result_validation,
'selectEducationalSystem' => '1',//大專院校
'selectCompany' => '',//學校
'studentNumber' => '',//學號
'login' => '確定',
'timingJavaScript$ctl03' => '');
$post = http_build_query($fields);
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 13);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HEADER, true);
$data=curl_exec($ch);
?>
--endcode--
不知道到底哪裡寫錯了...
有請協助....@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.165.217.199
1F:推 jimpop:請問這樣的CODE是正確的嗎?我也正遇到這種問題@@ 09/01 15:59
2F:→ s890510:最後我還有修改... 09/02 10:02