- 论坛徽章:
- 0
|
本帖最后由 fanasy 于 2010-11-13 22:15 编辑
以下是html的内容input
<input type="checkbox" id="chkboxProid4" value="45978663" name="rproid[]" v="1" onclick="selected('apf_id_15','chkboxProid4','myxxxxx1')" />- use diagnostics;
- use WWW::Mechanize;
- use Data::Dumper;
- use HTML::Form;
- use Encode;
- use WWW::Mechanize::Plugin::Display;
- my $name = Encode::decode('GB2312', '刷 新');
- #my $CACTIURL = "xxxxxxxxxxx";
- my $CACTIURL = "xxxxxxxxxxxxx";
- my $ADMINPASSWORD = "zhiyuan";
- #打开浏览器
- my $mech = WWW::Mechanize->new();
- #输入网址
- $mech->get($CACTIURL);
- #输入用户名密码
- $mech->set_visible("xxxxxx", $ADMINPASSWORD);
- $mech->click;
- #点击登陆
- my $link_m = $mech->find_link(url_regex => qr/W0QQactZsale/);
- my $value_hash =$link_m->url();
- $mech->get($link_m);
- $mech->form_number(2);
- my @inputs = $mech->current_form()->inputs();
- #print "inputs: @inputs\n";
- foreach my $input2 (@inputs) {
- my $input_type= $input2->type;
- my $input_id= $input2->id;
- my $input_value= $input2->value;
- my $input_name= $input2->name;
- if ($input_type eq "checkbox") {
- print "LOG: input_name $input_name\n";
- print "LOG: input_id $input_id\n";
- print "LOG: input_value $input_value\n";
- #$mech->field($input2=>'on');
- $mech->tick($input2->name,$input2->value);
- }
- }
- $mech->display;
- foreach my $input3 (@inputs) {
- my $input_value =$input3->id;
- #print "LOG:input_value $input_value\n";
- if($input_value eq "fresh0"){
- #print "LOG:input3 $input3\n";
- $mech->click_button(input=>$input3);
- }
- }
复制代码 麻烦熟悉html::form的看一下,不知道是不是和value是数字有关?
代码是为了实现自动 点击 指定的checkbox |
|