Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello! This is a repost of a problem that I just can get straightened out. I am trying write a Perl script to log into my router and open and close ports. I am able to log and and move around. I and able to retrieve data like IP address etc. But not able to check a checkbox or uncheck a checkbox. There are no errors, it just doesn't seem to update the checkboxes. As you can see from the code I have tried a few different things, without any luck though. I think that this is the HTML that I am working with.
<td width="10%" align="center"><input type="checkbox" name="EnBt0" val +ue="checkbox" CHECKED > </td>
Can anyone help? Thanks.
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize; my $url='http://192.168.0.1/WanService.html'; my $lo_url='http://192.168.0.1/logout.html'; my $mech = WWW::Mechanize->new( utocheck => 1 ); $mech->credentials( '192.168.0.1:80', 'FVS318', 'admin' => 'secret' ); # And then $mech->get() the same as in the LWP::UserAgent code my $response = $mech->get($url); die "Error at $url\n ", $response->status_line, "\n Aborting" unless $ +response->is_success; print "SUCCESS data type: ", $response->content_type, "\n\n"; #print "\n\n"; #print $response->content; $mech->tick('EnBt3', 'checkbox', 'CHECKED'); #$mech->current_form->POST( submit => { name => "Apply ", value =>"sub +mit" } ); #$mech->click_button(number => 2); #$mech->submit(); #$mech->submit(); $mech->success or die "post failed: ", $mech->response->status_line; my $lo_response = $mech->get($lo_url); die "Error at $lo_url\n ", $lo_response->status_line, "\n Aborting" un +less $lo_response->is_success; print "\n\nDone.\n\n";

In reply to screen scraping MECHANIZE by garskoci

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-23 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found