TaskPipe/UserAgentManager_ProxyNet_TOR.pm

filter: Statementstmt 65.0% 26 / 40 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 3 totaltotal 58.1% 32 / 55 CC 2 SCAR 7.8
CC
2
Cov
62%
init
6.0
__ANON__
2.0
before_request
2.0
CRAP 2.2
« TaskPipe/PathSettings.pm ↑ Summary TaskPipe.pm »
1 package TaskPipe::UserAgentManager_ProxyNet_TOR;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use MooseX::ClassAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Proc::ProcessTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use TaskPipe::UserAgentManager::UserAgentHandler;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use TaskPipe::TorManager;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 extends 'TaskPipe::UserAgentManager_ProxyNet';
10 1 with 'MooseX::ConfigCascade';
11  
12  
13  
14  
15 1 has rotate_ip => (is => 'ro', isa => 'Bool', lazy => 1, default => 1);
16  
17 has tor_manager => (is => 'ro', isa => 'TaskPipe::TorManager', lazy => 1, default => sub{
18 0 ▶ TaskPipe::TorManager->new(
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 #thread_id => $_[0]->thread_id,
20 gm => $_[0]->gm
21 #job_id => $_[0]->job_id
22 );
23 1 });
24  
25 1 class_has initialized => (is => 'rw', isa => 'Bool');
26  
27 1 has gm => (is => 'rw', isa => 'TaskPipe::SchemaManager');
28  
29  
30  
31  
32  
33 sub init{
34 0 ▶ my $self = shift;
Subroutine init: not called CC=2 SCAR=17.9
Pod undocumented
35  
36 #$self->tor_manager->thread_id( $self->thread_id );
37 0 $self->tor_manager->connect_socket;
38  
39 0 $self->ua_handler->call(
40 'proxy',
41 $self->tor_manager->settings->protocols,
42 $self->tor_manager->url
43 );
44  
45 0 ▶ if ( ! $self->initialized ){
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->initialized) 0 0 0
46 0 $self->initialized( 1 );
47 }
48 }
49  
50  
51  
52 sub before_request{
53 0 ▶ my ($self) = @_;
Subroutine before_request: not called CC=1 SCAR=6.9
Pod undocumented
54  
55 #$self->mu->record("before_request: at start");
56 0 $self->ua_handler->ua( $self->ua_handler->build_ua );
57  
58 #$self->mu->record("before_request: after build ua");
59 0 $self->ua_handler->call(
60 'proxy',
61 $self->tor_manager->settings->protocols,
62 $self->tor_manager->url
63 );
64  
65 #$self->mu->record("before_request: at end");
66 }
67  
68  
69 sub change_ip{
70 0 ▶ my $self = shift;
Subroutine change_ip: not called CC=1 SCAR=6.9
Pod undocumented
71  
72 0 $self->tor_manager->change_ip;
73 #$self->check_ip;
74 0 $self->set_max;
75 0 $self->cur_rno(0);
76 0 $self->ua_handler->clear_cookies;
77  
78 }
79  
80 =head1 NAME
81  
82 TaskPipe::UserAgentManager_ProxyNet_TOR - useragent manager for making requests through TOR
83  
84 =head1 DESCRIPTION
85  
86 This is the useragent manager for making requests through the TOR network. You need to have TOR installed and set up on your system, and you should check the settings you have in your global config under the C<TaskPipe::TorManager::Settings> section make sense for your system.
87  
88 You can use this class with L<TaskPipe::Task_Scrape> by specifying it as the useragent manager to use in your project config.
89  
90 TaskPipe::Task_Scrape::Settings:
91 ua_mgr_module: TaskPipe::UserAgentManager_ProxyNet_TOR
92 # ...
93  
94 =head1 SEE ALSO
95  
96 L<TaskPipe::UserAgentManager>
97 L<TaskPipe::UserAgentManager_ProxyNet>
98 L<TaskPipe::UserAgentManager::UserAgentHandler>
99  
100 =head1 AUTHOR
101  
102 Tom Gracey <tomgracey@gmail.com>
103  
104 =head1 COPYRIGHT AND LICENSE
105  
106 Copyright (c) Tom Gracey 2018
107  
108 TaskPipe is free software, licensed under
109  
110 The GNU Public License Version 3
111  
112 =cut
113  
114 1 __PACKAGE__->meta->make_immutable;
115 1 1;
116 __END__
« TaskPipe/PathSettings.pm ↑ Summary TaskPipe.pm »