<html>스크리핑 실행하는 perl 모듈
<head><title>test</title>
<body>
<form>
<input type=hidden name="hidden1" value="v_h1">
<input type=text name="txt1" value="v_txt1">
<input type=text name="txt2" value="v_txt2">
<input type=hidden name="hidden2" value="v_txt2">
<input type=checkbox name="chk1" value="v_chk1" >
<input type=checkbox name="chk1" value="v_chk2" checked>
<input type=radio name="rdo1" value="v_rdo1" >
<input type=radio name="rdo1" value="v_rdo2" checked>
<textarea name='txt_desc'>haha</textarea>
</form>
</body>
</html>
use WWW::Mechanize;
use Data::Dumper;
#############################
# begin of test part
# form 값을 parsing
my $agent = WWW::Mechanize->new( );
$agent->get( "http://scm.ezadmin.co.kr/test_form.html" );my @forms = $agent->forms();
my $form = $forms[0];print Dumper $form;
print "\n ============================ \n";
# Check all the boxes
foreach my $input ( @{$form->{inputs}} ) {
print $input->{name} , "/" ;# hidden, text 처리
if ( $input->{type} eq "text" or $input->{type} eq "hidden" or $input->{type} eq "textarea" )
{
print $input->{value}, "\n";
}
elsif ( $input->{type} eq "checkbox" or $input->{type} eq "radio" )
{
my $current = $input->{current};
print $input->{menu}[$current]->{value} . "\n";
}
}
댓글 없음:
댓글 쓰기