Mechanize 模块 可以提交form,实现登录功能

Mechanize 模块 可以提交form,实现登录功能 :
#!/usr/bin/perl
BEGIN {

	# Set our common library path.
	unshift @INC, './lib';
}

require HTTP::Request;
require HTTP::Response;
require HTTP::Headers;
require HTTP::Cookies;
require LWP;
use WWW::Mechanize;
use Data::Dumper;
use Encode;

#my $ua = LWP::UserAgent->new;
#
#$ua->agent(
#'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11 GTB7.1 ( .NET CLR 3.5.30729)'
#);
#my $login_response = $ua->post(
#	'http://www.zeel.jp/outlet/item.jsp?GOODS_NO=88636&dispNo=010010001035',
#	'Cookie' => 'JSESSIONID=E0A35234BD47293353BA5B87541C8BA9',
#);
#
#if ($login_response->is_success){
#	print decode ('Shift_JIS',Dumper $login_response);
#} else {
#	print 456;
#}

my $mech = WWW::Mechanize->new(
	agent =>
	  'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11 GTB7.1 ( .NET CLR 3.5.30729)',
	cookie_jar => {}
);
print 11;
$mech->get('http://www.zeel.jp/select/');

$mech->dump_forms( );
$mech->dump_links(undef,1);


print 22;

$mech->form_number(1);
$mech->field( ID  => 'kankan' );
$mech->field( PWD => 'kankan' );
$mech->click("Submit");

print "After Login Cookie: ";
print $mech->cookie_jar->as_string();
print "\n";

my $searchURL = 'http://www.zeel.jp/outlet/item.jsp?GOODS_NO=88636&dispNo=010010001035';
my $res = $mech->get($searchURL);
print "After Search Cookie: ";
print $mech->cookie_jar->as_string();
print "\n";
print decode('Shift_JIS',$res->content);

你可能感兴趣的:(windows,.net,jsp,perl,firefox)