Re: Programmatic web form fill-in?
Re: Programmatic web form fill-in?
- Subject: Re: Programmatic web form fill-in?
- From: John Pannell <email@hidden>
- Date: Thu, 6 Apr 2006 08:48:29 -0600
Hi Bob-
I just did something similar using the DOM via Cocoa. Here's a
snippet that fills out form elements and submits the form...
inputKeys is an array of keys for the desired form elements, and
inputValues is an array of corresponding values for the keys...
// search form for same key value pairs and set values
DOMDocument *document = [frame DOMDocument];
DOMNodeList *formNodeList = [document
getElementsByTagName:@"FORM"];
int i;
for(i=0; i < [formNodeList length]; i++){
BOOL authForm = NO;
DOMHTMLFormElement *formNode = (DOMHTMLFormElement *)
[formNodeList item:i];
// get inputs from form
DOMNodeList *inputNodeList = [formNode
getElementsByTagName:@"INPUT"];
int j;
for(j = 0; j < [inputNodeList length]; j++){
DOMHTMLInputElement *inputNode =
(DOMHTMLInputElement *)[inputNodeList item:j];
if([inputKeys containsObject:[inputNode name]]){
[inputNode setValue:[inputValues objectAtIndex:
[inputKeys indexOfObject:[inputNode name]]] forKey:@"value"];
authForm = YES;
}
}
if(authForm){
// submit this form
[formNode submit];
}
}
Hope this helps!
John
On Apr 6, 2006, at 8:36 AM, Bob Estes wrote:
I would like to be able to fill in an online html form from within
a cocoa program. I assume a webview will enable me to display the
form within my program, but how can I fill it in with my already
chosen text/string with a click of a (cocoa) button?
Thanks,
Bob Estes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40positivespinmedia.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden