Press a button

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I want to make a perl script that presses the Disconnect button of the
below html code. I found some code but still I am not able to press the
button. Can someone help me please with some code?


<form name='PPPConn0' action='/cgi/b/is/' method='post'>
<input type='hidden' name='0' value=''>
<input type='hidden' name='1' value=''>
<input type='hidden' name='2' value='279867884'>
<div class='contentitem'>
<table cellspacing='0' cellpadding='0'>
<tr><td class='icon' valign='top' width='100px'><img
src='/images/cintgrxl.gif' alt='Internet Connection OK'></td>
<td class='data' valign='top'><table cellspacing='0'
cellpadding='0'><tr><td align='left'><span
class='itemtitle'>INTERNET</span></td><td align='right'><input
type='button' name='13' value='Disconnect'
onClick='submitForm(document.PPPConn0,13,0,"INTERNET","",0,"")' >
<tr><td colspan='2'><input type='hidden' name='5' value="2">
<br><table cellspacing='0' cellpadding='0' width='100%'><tr><td
width='40' valign='top'><img src='/images/bull__md.gif' alt=''></td><td
<span class='blocktitle'><a
'name=INTERNET')">View more...</a></span><br>

Re: Press a button

pod wrote:

Quoted text here. Click to load it

What sort of script would the user be connecting to/using?  In what way
are you attempting to "disconnect" them?  Just ending their active
session, preventing them from continuing with said session, or?  Sorry,
I didn't bother reading through the HTML source you had posted, as it
doesn't really offer the information needed to give you the best
answer.  Is this a Perl script in CGI, or some specific service?
Tim Greer, CEO/Founder/CTO,, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

Re: Press a button

pod wrote:
Quoted text here. Click to load it

What's the source code of this submitForm(...) part?



Re: Press a button

Quoted text here. Click to load it

You misunderstand how this web stuff works.

The button is in the browser.

Perl programs do not run in a browser.

You cannot "press the button" in the browser from a Perl program.

What you _can_ do is to figure out what HTTP request the browser
sends when you click that button, then write a Perl program that
sends that same HTTP request.

If it were me, I'd set up the Web Scraping Proxy, click the
button in the browser, and then go see what has logged
for me.

Quoted text here. Click to load it

Let's see it. We cannot debug code that we cannot see.

Quoted text here. Click to load it

Another way to figure out what request is being made is to figure
out what submitForm() does.

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Re: Press a button


My aim is to make a script that pushes 2 buttons on my routers
webinterface so that the router can get a new ip. The html shows the
code of the button. I just have to press somehow the button is the html
code not enough information to make a little script that pushes the
Disconnect button?

I found something on the web but i dont know if its useful an example
that searches for someting and also presses a button?

  use LWP::UserAgent;
   $ua = LWP::UserAgent->new;
   $ua->agent("MyApp/0.1 ");

   # Create a request
   my $req = HTTP::Request->new(POST => '');

   # Pass request to the user agent and get a response back
   my $res = $ua->request($req);

   # Check the outcome of the response
   if ($res->is_success) {
       print $res->content;
   else {
       print $res->status_line, "\n";

pod schrieb:
Quoted text here. Click to load it

Re: Press a button

[ Please do not top-post! ]

Quoted text here. Click to load it

Yes, the html code is not enough (because there is some JavaScript
in the middle).

You need to discover what HTTP request is being sent.

Quoted text here. Click to load it

This module (or WWW::Mechanize which subclasses it) will almost
surely be part of the solution.

How to make it into the solution depends on ...

... what HTTP request is being sent.

[ snip upside-down quote ]

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Site Timeline