TaskPipe/OpenProxyManager/IPList_Xroxy.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%
url_from_page_index
2.0
page_index_url
2.0
scrape_page_index
2.0
CRAP 2.0
1 package TaskPipe::OpenProxyManager::IPList_Xroxy;
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 ws => (is => 'ro', isa => 'Web::Scraper', default => sub{
11 scraper {
12 process 'tr.row0,tr.row1', 'row[]' => scraper {
13 process_first 'td:nth-child(2) a', 'ip' => 'TEXT';
14 process_first 'td:nth-child(3) a', 'port' => 'TEXT';
15 };
16 result 'row';
17 };
18 });
19  
20 has page_index_ws => (is => 'ro', isa => 'Web::Scraper', default => sub{
21 scraper {
22 process_first 'table.tbl table tr:last-child td b', 'num_proxies' => 'TEXT';
23 result 'num_proxies';
24 };
25 });
26  
27  
28 sub url_from_page_index{
29 my ($self,$page_i) = @_;
30  
31 my $f_page_i = $page_i - 1;
32 my $url = $self->list_settings->url_template;
33 $url =~ s/<page>/$page_i/;
34 return $url;
35  
36 }
37  
38  
39 has list_settings => (
40 is => 'ro',
41 isa => 'TaskPipe::OpenProxyManager::IPList_Xroxy::Settings'
42 );
43  
44  
45  
46 sub page_index_url{
47 my ($self) = @_;
48  
49 $self->url_from_page_index( 0 );
50 }
51  
52  
53 sub scrape_page_index{
54 my ($self,$resp,$url) = @_;
55  
56 my $num_proxies = $self->page_index_ws->scrape( $resp->decoded_content, $url );
57 my $max_page = int( $num_proxies / +$self->list_settings->proxies_per_page );
58 return +[0..$max_page];
59 }
60  
61  
62 =head1 NAME
63  
64 TaskPipe::OpenProxyManager::IPList_Xroxy - Xroxy IP List
65  
66 =head1 DESCRIPTION
67  
68 Provides methods to get the IP List from the Xroxy service. It is not recommended to use this package directly
69  
70 =head1 AUTHOR
71  
72 Tom Gracey <tomgracey@gmail.com>
73  
74 =head1 COPYRIGHT AND LICENSE
75  
76 Copyright (c) Tom Gracey 2018
77  
78 TaskPipe is free software, licensed under
79  
80 The GNU Public License Version 3
81  
82  
83 =cut
84  
85 1;