I have a sample form code for the login page (http://**.com/def.php) page:
I called com "internetexplorer.application" by PHP to fill out the form and log in, the code is as follows:
HWND; $Browser->visible = true; $f 1_url = "http://**.com/def.php"; $Browser->navigate ($f 1_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 ();? >
It is in the name attribute to find the element to be controlled, but if I change the form code of the sample page to:
I called com "internetexplorer.application" by PHP to fill out the form and log in, the code is as follows:
HWND; $Browser->visible = true; $f 1_url = "http://**.com/def.php"; $Browser->navigate ($f 1_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 ();? >
It is in the name attribute to find the element to be controlled, but if I change the form code of the sample page to:
Change "name=" f_action "" to " No Name attribute ", so how can the PHP code be rewritten in order to allow COM "internetexplorer.application" to fill out the form and log in?
Thank!
These two days, the net answer to the DOM-related questions ... I don't know why ...
The amount ... The above is an off-topic ... You have this problem ... If you can write it here ... It should not be difficult to move on ...
Programming in addition to rigorous ... Sometimes in the face of the problem do not know also need to imaginative imagination and not afraid of the wall of the attempt ...
HWND; $Browser->visible = true; $f 1_url = "http://**.com/def.php"; $Browser->navigate ($f 1_url); sleep (5);/* $ AllForms is isn't an array ... it's an iterator ... */$allforms = $Browser->document->getelementsbytagname (' form '); /* Current () was not implemented ... so we had to run a loop ... */foreach ($allforms as $theform) {/ * I also copied These six lines and did some text replace work ... * /$theform->id->focus (); $theform->id->value = "username"; $theform->pwd->focus (); $theform->pwd->value = "password"; $theform->action->focus (); $theform->action->click (); } /* Bye browser ... has a nice day ... */$Browser->quit ();
In fact you can handle all the elements on the page ... This is the truth ...
nn ... That's it.