line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HDML::LinkExtor; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
48108
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION @ISA); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
924
|
|
5
|
|
|
|
|
|
|
require HTML::Parser; |
6
|
|
|
|
|
|
|
require HTML::LinkExtor; |
7
|
|
|
|
|
|
|
@ISA = qw(HTML::Parser HTML::LinkExtor); |
8
|
|
|
|
|
|
|
$VERSION = '0.02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %hdml_tagset_linkelements = ( |
11
|
|
|
|
|
|
|
'a' => ['dest'], |
12
|
|
|
|
|
|
|
'action' => ['dest'], |
13
|
|
|
|
|
|
|
'ce' => ['dest'], |
14
|
|
|
|
|
|
|
'img' => ['src'], |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
13
|
my ($class, $cb, $base) = @_; |
19
|
1
|
|
|
|
|
20
|
my $self = $class->SUPER::new( |
20
|
|
|
|
|
|
|
start_h => ["_start_tag", "self, tagname, attr"], |
21
|
|
|
|
|
|
|
report_tags => [keys %hdml_tagset_linkelements], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
98
|
$self->{extractlink_cb} = $cb; |
25
|
1
|
50
|
|
|
|
4
|
if ($base) { |
26
|
1
|
|
|
|
|
3173
|
require URI; |
27
|
1
|
|
|
|
|
5669
|
$self->{extractlink_base} = URI->new($base); |
28
|
|
|
|
|
|
|
} |
29
|
1
|
|
|
|
|
11365
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _start_tag { |
33
|
8
|
|
|
8
|
|
230
|
my ($self, $tag, $attr) = @_; |
34
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
16
|
my $base = $self->{extractlink_base}; |
36
|
8
|
|
|
|
|
14
|
my $links = $hdml_tagset_linkelements{$tag}; |
37
|
8
|
50
|
|
|
|
23
|
$links = [$links] unless ref $links; |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
9
|
my @links; |
40
|
8
|
|
|
|
|
13
|
for my $a (@$links) { |
41
|
8
|
50
|
|
|
|
22
|
next unless exists $attr->{$a}; |
42
|
8
|
100
|
|
|
|
29
|
next if $attr->{$a} =~ /^#.*/; |
43
|
7
|
50
|
|
|
|
16
|
my $method = $attr->{method} ? uc($attr->{method}) : 'GET'; |
44
|
7
|
|
|
|
|
9
|
my $postdata = $attr->{postdata}; |
45
|
7
|
50
|
|
|
|
153
|
my $absbase = $base ? |
46
|
|
|
|
|
|
|
URI->new($attr->{$a}, $base)->abs($base) : $attr->{$a}; |
47
|
7
|
|
|
|
|
3162
|
push(@links, $a, $absbase, $method, $postdata); |
48
|
|
|
|
|
|
|
} |
49
|
8
|
100
|
|
|
|
29
|
return unless @links; |
50
|
7
|
|
|
|
|
31
|
$self->_found_link($tag, @links); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |