我应该如何检查这样的复选框:
<td><center><INPUT name="test2%40mydomain.com_notmetoo" type="CHECKBOX" value="off" ></center></td>
使用 Perl 的 LWP::UserAgent 模块?
此代码不执行此操作(输出就好像它是在未选中复选框的情况下提交的 - 即网页被刷新并且复选框被清除)。
#!/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;
}
我不确定为什么元素名称中的“@”由“%40”表示(有什么想法吗?),但我也尝试过: 'test2\%40mydomain.com_notmetoo' => 'on', 和 ' test2@mydomain.com_notmetoo' => 'on', 没有成功。
网站上似乎没有 JavaScript(即它在禁用 JavaScript 的浏览器中运行良好)。我只是无法让它在 Perl 中工作。
谢谢。
特里。
更新 #1:这是我在检查 Test2 的 notmetoo 框后提交时来自 Firefox 的“篡改数据”扩展的 POSTDATA 值:
POSTDATA =-----------------------------2921376274802
Content-Disposition: form-data; name="findmember"
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_realname"
Test1
-----------------------------2921376274802
Content-Disposition: form-data; name="user"
test1%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_hide"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_notmetoo"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_plain"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_language"
en
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_realname"
Test2
-----------------------------2921376274802
Content-Disposition: form-data; name="user"
test2%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_hide"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_notmetoo"
off
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_plain"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_language"
en
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_realname"
Test3
-----------------------------2921376274802
Content-Disposition: form-data; name="user"
test3%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_hide"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_plain"
on
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_language"
en
-----------------------------2921376274802
Content-Disposition: form-data; name="setmemberopts_btn"
Submit Your Changes
-----------------------------2921376274802
Content-Disposition: form-data; name="allmodbit_val"
0
-----------------------------2921376274802--
这对任何人帮助我有帮助吗?