tel2 has asked for the wisdom of the Perl Monks concerning the following question:
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:
And here's the code I've written in an attempt to check the above "notmetoo" checkbox for the test2@mydomain.com email address:<td><center><INPUT name="test2%40mydomain.com_notmetoo" type="CHEC +KBOX" value="off" ></center></td>
Unfortunately, the above does not work. It prints my "Changed user setting...I hope!" line, but the setting doesn't get changed.#!/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; }
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:
I have also been able to sucessfully check other checkboxes on other Mailman webpages.$res = $ua->post('http://mydomain.com/mailman/admin/test1_mydomain +.com/members/list', Content_Type => 'form-data', Content => [ findmember => 'Test2', findmember_btn => 'Search...' ] );
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unable to check checkbox via LWP::UserAgent
by Gangabass (Vicar) on Aug 15, 2012 at 00:42 UTC | |
by tel2 (Pilgrim) on Aug 15, 2012 at 01:17 UTC | |
|
Re: Unable to check checkbox via LWP::UserAgent
by tobyink (Canon) on Aug 15, 2012 at 06:10 UTC | |
by tel2 (Pilgrim) on Aug 16, 2012 at 09:59 UTC | |
by tobyink (Canon) on Aug 16, 2012 at 10:28 UTC | |
by tel2 (Pilgrim) on Aug 19, 2012 at 21:54 UTC | |
|
Re: Unable to check checkbox via LWP::UserAgent
by Anonymous Monk on Aug 15, 2012 at 02:21 UTC | |
by tel2 (Pilgrim) on Aug 16, 2012 at 03:16 UTC |