Changeset 233
- Timestamp:
- 03/02/06 10:35:05
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/CustomFeed/Frepa.pm
r226 r233 18 18 sub load { 19 19 my($self, $context) = @_; 20 $self->{frepa} = Plagger::Plugin::CustomFeed::Frepa::Mechanize->new($self ->conf->{livedoor_id}, $self->conf->{password});20 $self->{frepa} = Plagger::Plugin::CustomFeed::Frepa::Mechanize->new($self); 21 21 22 22 my $feed = Plagger::Feed->new; … … 28 28 my($self, $context, $args) = @_; 29 29 30 31 30 unless ($self->{frepa}->login) { 32 $context->log(error => "Login failed.");31 $context->log(error => "Login to frepa failed."); 33 32 return; 34 33 } 35 34 36 $context->log(info => 'Login to frepa succeed .');35 $context->log(info => 'Login to frepa succeeded.'); 37 36 38 37 my $feed = Plagger::Feed->new; … … 113 112 sub new { 114 113 my $class = shift; 114 my $plugin = shift; 115 116 my $mech = WWW::Mechanize->new(cookie_jar => $plugin->cache->cookie_jar); 117 $mech->agent_alias( "Windows IE 6" ); 115 118 116 119 bless { 117 mecha => WWW::Mechanize->new, 118 livedoor_id => shift, 119 password => shift, 120 121 login_url => 'http://member.livedoor.com/login/?.next=http%3A%2F%2Ffrepa.livedoor.com&.sv=frepa&.nofrepa=1', 120 mecha => $mech, 121 livedoor_id => $plugin->conf->{livedoor_id}, 122 password => $plugin->conf->{password}, 123 start_url => 'http://www.frepa.livedoor.com/', 122 124 }, $class; 123 125 } … … 126 128 my $self = shift; 127 129 128 my $res = $self->{mecha}->get($self->{ login_url});130 my $res = $self->{mecha}->get($self->{start_url}); 129 131 return 0 unless $self->{mecha}->success; 130 132 131 $self->{mecha}->set_fields(livedoor_id => $self->{livedoor_id}, password => $self->{password}); 132 my $res = $self->{mecha}->submit; 133 return 0 unless $self->{mecha}->success; 134 return 0 if $self->{mecha}->content =~ /loginside/; 133 if ($self->{mecha}->content =~ /loginside/) { 134 Plagger->context->log(debug => "cookie not found. logging in"); 135 $self->{mecha}->submit_form( 136 fields => { 137 livedoor_id => $self->{livedoor_id}, 138 password => $self->{password}, 139 auto_login => 'on', 140 }, 141 ); 142 $self->{mecha}->submit; 143 return 0 unless $self->{mecha}->success; 144 return 0 if $self->{mecha}->content =~ /loginside/; 145 } 135 146 136 147 return 1;
