Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

How to automate a form with javascript

by romy_mathew (Beadle)
on Jul 26, 2012 at 17:38 UTC ( [id://983890]=perlquestion: print w/replies, xml ) Need Help??

romy_mathew has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I was trying to automate an sms function with free sms site "http://www.160by2.com". I am having a problem in submitting a form with java action at the message page

I am posting the code I was trying to achive below.

#!/usr/bin/perl -w use strict; use WWW::Mechanize; my $browser = WWW::Mechanize->new(); $browser->agent('User-Agent=Mozilla/5.0 (Macintosh; U; Intel Mac OS X +10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'); my $url ='http://www.160by2.com/Login'; my $result = $browser->get($url); die "GET failed" unless $result->is_success; print "Opned the Login Page\n"; $result = $browser->submit_form( form_number => 1, fields => { username => '9400791900', password => '123456' } ); die "SUBMIT FAILED" unless $result->is_success; print "Passed the Login Page\n"; my $message = $browser->get('http://www.160by2.com/SendSMS?id=3E6145C7 +9AEE54A1FBAE529AE0AA48A6.03'); die "URL Follow failed" unless $message->is_success; print "sucessfully login inside the Message Page\n"; print "printing the current page fetched \n"; =comment open ("FILE","> log.txt") or die "cannnot able to open the file for wr +itting\n"; print FILE $browser->content; close(FILE); $message = $browser->submit_form( form_name => 'frm_sendsms', fields => { mobile1 => '9400791900', msg1 => 'Hello a Test Message from romy', btnsendsms => 'Send Now' } ); =cut $browser->form_name("frm_sendsms"); $browser->field("mobile1","9400791900"); $browser->field("msg1","Hi Dear I am from lap"); $browser->submit(); die "SUBMIT FAILED" unless $browser->success(); print "Passed the Message Page\n";

Replies are listed 'Best First'.
Re: How to automate a form with javascript
by zentara (Archbishop) on Jul 26, 2012 at 17:53 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://983890]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2024-04-18 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found