ref:http://www.blueshop.com.tw/board/FUM20041006152627A9N/BRD20130417225944UFH/2.html
<?php $browser = new COM("InternetExplorer.Application") or die("can not start internet explorer"); $browser->Visible = true; $browser->Navigate("http://php.a168a.com/andyto202/login.php"); while (($browser->Busy) || ($browser->readystate != 4) ) { com_message_pump(1000); } $browser->Document->passForm->username->INNERTEXT = "abcdef"; $browser->Document->passForm->password->INNERTEXT = "123456"; com_message_pump(2000); //隔兩秒才送出才看得到結果 $browser->Document->passForm->Submit->Click; //在這裡判斷$iecontent;正確進入才存入cookie; while (($browser->Busy) || ($browser->readystate != 4) ) { com_message_pump(2000); } $string = "錯誤"; $iecontent = $browser->Document->body->INNERTEXT; $iecontent = iconv("big5","UTF-8",$iecontent); if (strpos($iecontent,"錯誤")) { //還有很多判斷例如無此帳號....,每個網頁不一樣請自行增加 echo $iecontent; } else { echo "write cookie ok"; $iecookie = $browser->Document->cookie; echo $iecookie; } $browser->Quit(); ?>
沒有留言:
張貼留言