robot script that logs me in and fills forms automatically
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
robot script that logs me in and fills forms automatically
Can someone please tell me how to make a script in php or maybe any other lang. that can log me into any website and fill up a form.
Please post any links or whatever solution that anyone might be having. The form is in .aspx format.
Like suppose I have to submit question to LQ so I will login using this php script and fill up the form
Such a script is what I am looking for.
Can someone please tell me how to make a script in php or maybe any other lang. that can log me into any website and fill up a form.
Please post any links or whatever solution that anyone might be having. The form is in .aspx format.
Like suppose I have to submit question to LQ so I will login using this php script and fill up the form
Such a script is what I am looking for.
PHP is a bad language for this (otherwhise also )
I recommend writing it in java.
I made once such a program. You just have to analyze the traffic that is being send and received from the webserver.
After that you can open a socket and generate these packets yourself.
If you don't know Perl, you might struggle a bit ;-), or of course you can learn it....
It's a very good lang... anyway, here's a short example to get you started
Code:
#!/usr/bin/perl -w
use WWW::Mechanize; # Automate website interactions
use strict; # Enforce declarations
my (
$mech, # www::mechanize obj
$error_msg # generic msg holder
);
# Create Mech Obj
$mech = WWW::Mechanize->new() or
exit_with_error("Mech Obj create failed: $@");
# Get login screen
$mech->get($cfg::params{'TGT_URL'}) or
exit_with_error("Get URL $cfg::params{'TGT_URL'} failed: $@");
#DEBUG
#$error_msg = $mech->uri();
#print "URI: $error_msg\n";
# Fill in Login credentials and submit form to website
$mech->submit_form( fields =>
{
username => $cfg::params{'USER'},
password => $cfg::params{'PASSWD'}
}
);
if( !$mech->success() )
{
exit_with_error("Submit Login form failed: $@");
}
#DEBUG
#$error_msg = $mech->uri();
#print "URI: $error_msg\n";
# Should have received Phone/Msg form, so
# fill in nums(s), msg and submit form to website
$mech->submit_form( fields =>
{
numbers => $cfg::params{'PHONE_NUM'},
message => $cfg::params{'MESSAGE'}
}
);
if( !$mech->success() )
{
exit_with_error("Submit Message form failed: $@");
}
#DEBUG
#$error_msg = $mech->uri();
#print "URI: $error_msg\n";
# Should have got "Confirmation" screen: click Continue button
$mech->click_button(number => 1);
if( !$mech->success() )
{
exit_with_error("Submit Confirmation form failed: $@");
}
RE: robot script that logs me in and fills forms automatically
I find that http://search.cpan.org is very helpful with function documentation of the modules. The page is here for WWW:Mechanize.
For perl syntax I found this site good (even though it is for windows)
And here is the perl.net.au wiki tutorial
That should give you a reasonably good background to it all
And of course I am glad to help you where I can (I am still learning Perl as well )
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.