/usr/share/perl5/WWW/Freshmeat/User.pm is in libwww-freshmeat-perl 0.22-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | package WWW::Freshmeat::User;
use strict;
use warnings;
use WWW::Freshmeat ();
use Carp;
our $VERSION = '0.22';
sub init_html {
croak "removed";
my $self = shift;
my $html = shift;
require HTML::TreeBuilder::XPath;
$self->{_html}=HTML::TreeBuilder::XPath->new_from_content($html);
}
sub _html_tree {
my $self = shift;
if (!$self->{_html}) {
my $id=$self->{id};
my $url = "http://freshmeat.net/~$id/";
$self->{www_freshmeat}->agent('User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.1.19) Gecko/20081201 Firefox/2.0.0.19');
my $response = $self->{www_freshmeat}->get($url);
my $html = $response->content();
if ($response->is_success) {
if ($html=~m#<p>\s*Invalid user ID\s*</p>#s) {
return;
}
$self->init_html($html);
} else {
die "Could not GET $url (".$response->status_line.", $html)";
}
}
return $self->{_html};
}
sub new {
croak "removed";
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
$self->{www_freshmeat} = shift;
$self->{id} = shift;
return $self;
}
sub projects {
my $self = shift;
my $tree=$self->_html_tree();
my $xpath=q{/html/body/div[1]/table/tr/td[2]/table/tr[1]/td[2]/p/ul[1]/li/a};
my $nodes=$tree->findnodes($xpath);
my @list;
while (my $node=$nodes->shift) {
if ($node->attr('href') =~m#/projects/($WWW::Freshmeat::Project::project_re)/#) {
push @list,$1;
} else {
die;
}
}
return @list;
}
1
# (c) Alexandr Ciornii, 2009
|