html - 藉由PHP呼叫COM “InternetExplorer.Application”,如何不用name属性模拟用户登入?
程序员文章站
2022-05-29 15:29:41
...
我有一个登入页面(http://**.com/def.php)页的表单代码范例:
我藉由PHP呼叫COM “InternetExplorer.Application”去填写表单并登入,代码如下:
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”去填写表单并登入,代码如下:
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 发送带附件邮件示例_PHP