Hi Monks,

I'm using Perl's LWP::UserAgent module and I'd like to check/uncheck checkboxes in GNU Mailman's "Membership List" webpage.  Here's the element that I'm trying to change:

<td><center><INPUT name="test2%40mydomain.com_notmetoo" type="CHEC +KBOX" value="off" ></center></td>
And here's the code I've written in an attempt to check the above "notmetoo" checkbox for the test2@mydomain.com email address:
#!/usr/bin/perl use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->cookie_jar({ file => "$ENV{HOME}/.mailmanrc" }); $res = $ua->post('http://mydomain.com/mailman/admin/test1_mydomain +.com/members/list', Content_Type => 'form-data', Content => [ 'test2%40mydomain.com_notmetoo' => 'on', setmemberopts_btn => 'Submit Your Changes' ] ); if ($res->is_success) { print $res->decoded_content; print "Changed user setting...I hope!\n"; } else { die $res->status_line; }
Unfortunately, the above does not work. It prints my "Changed user setting...I hope!" line, but the setting doesn't get changed.

I'm not sure why the "@" is represented by "%40" in the element name (any ideas?), but I've also tried:
    'test2\%40mydomain.com_notmetoo' => 'on',
and
    'test2@mydomain.com_notmetoo' => 'on',
without success.

I've put the HTML which was generated by the "print $res->decoded_content" command here for you.
That output it what I would expect if I had just submitted the form without checking any box.  That is also what the webpage looks like before attempting to check the checkbox, so if you want to see that, it's the same.

Note that I have manually checked the "notmetoo" checkbox for Test1 via my browser, but Test2 is the one I'm trying to check with Perl.

I was able to use the "Find member" search on the same webpage, and that worked fine.  Here's an extract of that (working) code:

$res = $ua->post('http://mydomain.com/mailman/admin/test1_mydomain +.com/members/list', Content_Type => 'form-data', Content => [ findmember => 'Test2', findmember_btn => 'Search...' ] );
I have also been able to sucessfully check other checkboxes on other Mailman webpages.

Questions:
1. Can LWP::UserAgent be used to check the "nottome" checkbox (for example)?
2. What am I doing wrong?

I've spent many hours on this, and I'm getting nowhere fast, so your help would be appreciated.

Thanks.
Tel2


In reply to Unable to check checkbox via LWP::UserAgent by tel2

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.