TaskPipe/OpenProxyManager/IPList_ProxyNova.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 46 CC 1 SCAR 6.9
CC
1
Cov
0%
page_index_url
2.0
scrape_page_index
2.0
url_from_page_index
2.0
CRAP 2.0
1 package TaskPipe::OpenProxyManager::IPList_ProxyNova;
2  
3 use Moose;
4 extends 'TaskPipe::OpenProxyManager::IPList';
5 use Web::Scraper;
6 use Module::Runtime 'require_module';
7 use Data::Dumper;
8  
9  
10 has page_index_ws => (is => 'ro', isa => 'Web::Scraper', default => sub{
11 scraper {
12 process_first 'select[name=proxy_country]', 'country_select' => scraper {
13 process 'option', 'country_code[]' => '@value';
14 result 'country_code';
15 };
16 result 'country_select';
17 };
18 });
19  
20 has ws => (is => 'ro', isa => 'Web::Scraper', default => sub{
21 scraper {
22 process 'tr[data-proxy-id]', 'tr[]' => scraper {
23 process_first 'td:first-child', 'ip' => 'TEXT';
24 process_first 'td:nth-child(2) a', port => 'TEXT';
25 };
26 result 'tr';
27 }
28 });
29  
30  
31 has list_settings => (
32 is => 'ro',
33 isa => 'TaskPipe::OpenProxyManager::IPList_ProxyNova::Settings'
34 );
35  
36  
37  
38 sub page_index_url{
39 my ($self) = @_;
40  
41 return +$self->list_settings->countries_url;
42  
43 }
44  
45  
46 sub scrape_page_index{
47 my ($self,$resp,$url) = @_;
48  
49 my $index = $self->page_index_ws->scrape(
50 $resp->decoded_content,
51 $url
52 );
53 return $index;
54 }
55
56  
57  
58  
59 sub url_from_page_index{
60 my ($self,$country) = @_;
61  
62 my $url = $self->list_settings->url_template;
63 $url =~ s/<country_code>/$country/;
64 return $url;
65  
66 }
67  
68  
69 =head1 NAME
70  
71 TaskPipe::OpenProxyManager::IPList_ProxyNova - ProxyNova IP List
72  
73 =head1 DESCRIPTION
74  
75 Provides methods to get the IP List from the ProxyNova service. It is not recommended to use this package directly
76  
77 =head1 AUTHOR
78  
79 Tom Gracey <tomgracey@gmail.com>
80  
81 =head1 COPYRIGHT AND LICENSE
82  
83 Copyright (c) Tom Gracey 2018
84  
85 TaskPipe is free software, licensed under
86  
87 The GNU Public License Version 3
88  
89  
90 =cut
91  
92 __PACKAGE__->meta->make_immutable;
93 1;
94
95