line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Mechanize::PhantomJS::DSL; |
2
|
1
|
|
|
1
|
|
69535
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
719
|
use WWW::Mechanize::PhantomJS; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
657
|
use Object::Import; |
|
1
|
|
|
|
|
26368
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
49
|
use Carp qw(croak); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
173
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION= '0.24'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @CARP_NOT = (qw[ |
10
|
|
|
|
|
|
|
WWW::Mechanize::PhantomJS |
11
|
|
|
|
|
|
|
]); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
WWW::Mechanize::PhantomJS::DSL - Domain Specific Language for short scripts |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use WWW::Mechanize::PhantomJS::DSL '$mech'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
get 'http://google.de'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @links = selector('a'); |
24
|
|
|
|
|
|
|
print $_->get_text(),"\n" for @links; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
click($links[0]); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
print content; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module exports all methods of one WWW::Mechanize::PhantomJS |
31
|
|
|
|
|
|
|
object as subroutines. That way, you can write short scripts without |
32
|
|
|
|
|
|
|
cluttering every line with C<< $mech-> >>. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module is highly experimental and might vanish from the distribution |
35
|
|
|
|
|
|
|
again if I find that it is useless. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub import { |
40
|
1
|
|
|
1
|
|
12
|
my ($class, %options); |
41
|
1
|
50
|
|
|
|
4
|
if (@_ == 2) { |
42
|
0
|
|
|
|
|
0
|
($class, $options{ name }) = @_; |
43
|
|
|
|
|
|
|
} else { |
44
|
1
|
|
|
|
|
5
|
($class, %options) = @_; |
45
|
|
|
|
|
|
|
}; |
46
|
1
|
|
33
|
|
|
8
|
my $target = delete $options{ target } || caller; |
47
|
1
|
|
50
|
|
|
6
|
my $name = delete $options{ name } || '$mech'; |
48
|
1
|
|
|
|
|
9
|
my $mech = WWW::Mechanize::PhantomJS->new(%options); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
$name =~ s/^[\$]// |
51
|
|
|
|
|
|
|
or croak 'Variable name must start with $'; |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
113
|
|
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
*{"$target\::$name"} = \$mech; |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
import Object::Import \${"$target\::$name"}, |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
deref => 1, |
57
|
|
|
|
|
|
|
target => $target, |
58
|
|
|
|
|
|
|
; |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 AUTHORS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Max Maischein C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Copyright 2009-2020 by Max Maischein C. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This module is released under the same terms as Perl itself. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |