我有一个登入页面(http://**.com/def.php)页的表单代码范例:
我藉由PHP呼叫COM “InternetExplorer.Application”去填写表单并登入,代码如下:
<?php $Browser = new COM('InternetExplorer.Application'); $Browserhandle = $Browser->HWND; $Browser->Visible = true; $f1_url = "http://**.com/def.php"; $Browser->Navigate($f1_url); sleep(5); $Browser->Document->f_action->id->focus(); $Browser->Document->f_action->id->value = "username"; $Browser->Document->f_action->pwd->focus(); $Browser->Document->f_action->pwd->value = "password"; $Browser->Document->f_action->action->focus(); $Browser->Document->f_action->action->click(); $Browser->Quit(); ?>
里面是藉由Name属性找到要控制的元素,但若是我将范例页面的表单代码改成:
我藉由PHP呼叫COM “InternetExplorer.Application”去填写表单并登入,代码如下:
<?php $Browser = new COM('InternetExplorer.Application'); $Browserhandle = $Browser->HWND; $Browser->Visible = true; $f1_url = "http://**.com/def.php"; $Browser->Navigate($f1_url); sleep(5); $Browser->Document->f_action->id->focus(); $Browser->Document->f_action->id->value = "username"; $Browser->Document->f_action->pwd->focus(); $Browser->Document->f_action->pwd->value = "password"; $Browser->Document->f_action->action->focus(); $Browser->Document->f_action->action->click(); $Browser->Quit(); ?>
里面是藉由Name属性找到要控制的元素,但若是我将范例页面的表单代码改成: