Changeset 811
- Timestamp:
- 05/24/06 20:00:05
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Subscription/HatenaRSS.pm
r810 r811 18 18 19 19 my $username = $self->conf->{username} 20 or $context->error( 'username is missing');20 or $context->error("username is missing"); 21 21 22 my $start = "https://www.hatena.ne.jp/login?backurl=http%3A%2F%2Fr.hatena.ne.jp%2F"; 22 my $mech = Plagger::Mechanize->new(cookie_jar => $self->cookie_jar); 23 $mech->get("http://r.hatena.ne.jp/$username/opml"); 23 24 24 # support cookie_jar 25 my $mech = Plagger::Mechanize->new; 26 $mech->get($start); 25 if ($mech->content !~ /<opml version/) { 26 $mech->get("https://www.hatena.ne.jp/login?backurl=http%3A%2F%2Fr.hatena.ne.jp%2F"); 27 $mech->submit_form( 28 fields => { 29 key => $username, 30 password => $self->conf->{password}, 31 }, 32 ); 27 33 28 $mech->submit_form( 29 fields => { 30 key => $username, 31 password => $self->conf->{password}, 32 }, 33 ); 34 35 if ( $mech->content =~ m!<div class="error">! ) { 36 $context->log(error => "Login to HatenaRSS failed."); 37 return; 34 if ( $mech->content =~ m!<div class="error">! ) { 35 $context->log(error => "Login to HatenaRSS failed."); 36 return; 37 } 38 38 } 39 39 40 40 $context->log(info => "Login to HatenaRSS succeed."); 41 42 $mech->get("http://r.hatena.ne.jp/$username/config");43 $mech->submit_form(form_name => 'opmlexport');44 41 45 42 my $opml = $mech->content; … … 62 59 config: 63 60 username: example 64 password: xxxxxxxx65 61 66 62 =head1 DESCRIPTION 67 63 68 64 This plugin creates Subscription by fetching Hatena RSS 69 L<http://r.hatena.ne.jp> OPML by HTTP. Since Hatena RSS OPML export 70 requires login state, it uses WWW::Mechanize module to emulate the 71 browser's login authentication procedure. 65 L<http://r.hatena.ne.jp> OPML by HTTP. 66 67 If your OPML is shared public (which is default), you don't have to 68 pass password to the config. Also, even if you OPML is private, you 69 can share Cookies with your favorite browser like Firefox, using 70 71 global: 72 user_agent: 73 cookies: /path/to/cookies.txt 74 75 so that you don't have to pass password to the config, again. 72 76 73 77 =head1 AUTHOR
