File Coverage

blib/lib/WWW/RMDown.pm
Criterion Covered Total %
statement 18 36 50.0
branch 0 2 0.0
condition n/a
subroutine 6 8 75.0
pod 2 2 100.0
total 26 48 54.1


line stmt bran cond sub pod time code
1             package WWW::RMDown;
2              
3 1     1   39337 use strict;
  1         3  
  1         39  
4 1     1   5 use warnings;
  1         3  
  1         33  
5 1     1   1240 use utf8;
  1         17  
  1         5  
6 1     1   1541 use LWP::UserAgent;
  1         66861  
  1         38  
7 1     1   1145 use HTML::TagParser;
  1         21203  
  1         47  
8 1     1   1183 use autodie qw/open/;
  1         21140  
  1         8  
9              
10             our $VERSION = 0.01;
11              
12             sub new
13             {
14 0     0 1   my ($class, %cfg) = @_;
15 0           my $ua = LWP::UserAgent->new (agent => 'Mozilla/5.0', %cfg);
16 0           $ua->default_header ('Origin' => 'www.rmdown.com');
17              
18 0           bless {
19             'ua' => $ua
20             }, $class;
21             }
22              
23             sub fetch
24             {
25 0     0 1   my ($self, $hash) = @_;
26 0           my $ua = $self->{ua};
27 0           my %form = ();
28 0           my $contents;
29 0           my $sourceURL = 'http://www.rmdown.com/link.php?hash=' . $hash;
30              
31 0           my $html = HTML::TagParser->new ($sourceURL);
32 0           $ua->default_header ('Referrer' => $sourceURL);
33              
34 0           foreach my $input ($html->getElementsByTagName('input'))
35             {
36 0           my $name = $input->attributes->{'name'};
37 0           my $value = $input->attributes->{'value'};
38              
39 0           $form{$name} = $value;
40             }
41              
42 0           my $r = $ua->post ('http://www.rmdown.com/download.php', \%form);
43 0 0         $contents = $r->decoded_content if ($r->is_success);
44            
45 0           return $contents;
46             }
47              
48             1;
49              
50             __END__