Changeset 1686
- Timestamp:
- 09/15/06 03:15:56
- Files:
-
- trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm (modified) (1 diff)
- trunk/plagger/lib/Plagger/Plugin/CustomFeed/Simple.pm (modified) (3 diffs)
- trunk/plagger/lib/Plagger/Plugin/Filter/EntryFullText.pm (modified) (4 diffs)
- trunk/plagger/lib/Plagger/UserAgent.pm (modified) (3 diffs)
- trunk/plagger/t/plugins/CustomFeed-Simple/xpath.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/Aggregator/Simple.pm
r1577 r1686 51 51 52 52 my $agent = Plagger::UserAgent->new; 53 $agent->parse_head(0);54 53 my $response = $agent->fetch($url, $self); 55 54 trunk/plagger/lib/Plagger/Plugin/CustomFeed/Simple.pm
r1683 r1686 21 21 my($self, $context, $args) = @_; 22 22 23 if ( my $match = $args->{feed}->meta->{follow_link} || $args->{feed}->meta->{follow_xpath} ) { 24 $args->{match} = $match; 23 $args->{match} = $args->{feed}->meta->{follow_link}; 24 $args->{xpath} = $args->{feed}->meta->{follow_xpath}; 25 if ($args->{match} || $args->{xpath}) { 25 26 return $self->aggregate($context, $args); 26 27 } … … 50 51 $feed->link($url); 51 52 52 my $re = $args->{match}; 53 54 if( $args->{feed}->meta->{follow_link} ) { 53 if( my $re = $args->{match} ) { 55 54 my $resolver = HTML::ResolveLink->new(base => $url); 56 55 $content = $resolver->resolve($content); … … 74 73 $context->log(debug => "Add $token->[1]->{href} ($text)"); 75 74 } 76 } 77 else { 75 } elsif (my $xpath = $args->{xpath}) { 78 76 my $tree = HTML::TreeBuilder::XPath->new; 79 77 $tree->parse($content); 80 78 $tree->eof; 81 79 82 for my $child ( $tree->findnodes($ re|| '//a') ) {80 for my $child ( $tree->findnodes($xpath || '//a') ) { 83 81 my $href = $child->attr('href') or next; 84 82 my $title = $child->attr('title') || $child->as_text; trunk/plagger/lib/Plagger/Plugin/Filter/EntryFullText.pm
r1674 r1686 30 30 31 31 $self->{ua} = Plagger::UserAgent->new; 32 $self->{ua}->parse_head(0);33 32 } 34 33 … … 88 87 if ($handler) { 89 88 $args->{match} = $handler->custom_feed_follow_link; 89 $args->{xpath} = $handler->custom_feed_follow_xpath; 90 90 return $self->Plagger::Plugin::CustomFeed::Simple::aggregate($context, $args); 91 91 } … … 169 169 sub custom_feed_handle { 0 } 170 170 sub custom_feed_follow_link { } 171 sub custom_feed_follow_xpath { } 171 172 sub handle_force { 0 } 172 173 sub handle { 0 } … … 211 212 sub custom_feed_follow_link { 212 213 $_[0]->{custom_feed_follow_link}; 214 } 215 216 sub custom_feed_follow_xpath { 217 $_[0]->{custom_feed_follow_xpath}; 213 218 } 214 219 trunk/plagger/lib/Plagger/UserAgent.pm
r1640 r1686 12 12 my $class = shift; 13 13 my $self = $class->SUPER::new(@_); 14 $self->parse_head(0); 14 15 15 16 my $conf = Plagger->context ? Plagger->context->conf->{user_agent} : {}; … … 114 115 $url = URI->new($url) unless ref $url; 115 116 116 $self->parse_head(0);117 117 my $response = $self->fetch($url); 118 118 if ($response->is_error) { … … 134 134 $url = URI->new($url) unless ref $url; 135 135 136 $self->parse_head(0);137 138 136 my $response = $self->fetch($url); 139 137 if ($response->is_error) { trunk/plagger/t/plugins/CustomFeed-Simple/xpath.t
r1683 r1686 19 19 meta: 20 20 follow_xpath: //ul[@class="xoxo" or @class="subscriptionlist"]//a 21 21 22 22 - module: CustomFeed::Simple 23 23
