/* just copied six lines below ... */
$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$f1_url = "http://xxxxx.com";
$Browser->Navigate($f1_url);
sleep(10);
/* $allforms is NOT an array ... it is an iterator ... */
$allforms = $Browser->Document->getElementsByTagName( 'form' );
$i=0;
foreach( $allforms as $theform ) {
$i++;
if($i==3){
$theform->userID->focus();
$theform->userID->value = "xxxxx";
$theform->password->focus();
$theform->password->value = "xxxxx";
//$theform->submit->focus();
$theform->submit->click();
//$Browser->Quit();
}
}
while ($Browser->Busy) {
com_message_pump(4000);
}
sleep(10);
$filename=dirname(__FILE__).'/mar.html';
file_put_contents($filename,$Browser->document->body->innerhtml) ;
$Browser->Quit();
参考例子:http://segmentfault.com/q/1010000000174589