| 1 | package WWW::FreeProxy; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | our $VERSION = '0.04'; | |||||||||
| 6 | 2 | our @ISA = qw/Exporter/; | |||||||||
| 7 | 2 | our @EXPORT = qw/fetch_proxies/; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.0
| |||||||||||
| 10 | 2 | foreach my $dir (@INC) { | |||||||||
| 11 | 14 | ▶ | next unless -d ($dir . '/WWW/FreeProxy'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 6 | opendir $dir, $dir . '/WWW/FreeProxy'; | |||||||||
| 13 | 6 | map { eval { require "WWW/FreeProxy/$_" } } grep /\.pmc?$/, readdir $dir; | |||||||||
| 14 | 6 | closedir $dir; | |||||||||
| 15 | } | ||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | =head1 NAME | ||||||||||
| 19 | |||||||||||
| 20 | WWW::FreeProxy - fetch proxies from free proxy lists | ||||||||||
| 21 | |||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||
| 23 | |||||||||||
| 24 | use WWW::FreeProxy; | ||||||||||
| 25 | |||||||||||
| 26 | fetch_proxies { | ||||||||||
| 27 | # do whatever you need to do when new proxy is found | ||||||||||
| 28 | my $proxy = shift; | ||||||||||
| 29 | print "found new proxy: $proxy\n"; | ||||||||||
| 30 | }; | ||||||||||
| 31 | |||||||||||
| 32 | =head1 OVERVIEW | ||||||||||
| 33 | |||||||||||
| 34 | When the module is included it searches for all WWW::FreeProxy::* modules in @INC and loads them as plugins. It means that you can add your own plugins as ./WWW/FreeProxy/YourPlugin.pm. After that any calls to fetch_proxies() will go through all loaded plugins and call fetch() from them to get more proxies. | ||||||||||
| 35 | |||||||||||
| 36 | =head1 PLUGIN FORMAT | ||||||||||
| 37 | |||||||||||
| 38 | package WWW::FreeProxy::SamplePlugin; | ||||||||||
| 39 | |||||||||||
| 40 | sub fetch { | ||||||||||
| 41 | my ($self, $callback) = @_; | ||||||||||
| 42 | # find some proxies | ||||||||||
| 43 | &$callback($_) foreach @proxies; | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | =head1 FUNCTIONS | ||||||||||
| 47 | |||||||||||
| 48 | =head2 plugins() | ||||||||||
| 49 | |||||||||||
| 50 | Lists all currently loaded plugins. | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub plugins() { grep s/::$//, keys %WWW::FreeProxy:: } | ||||||||
|
Subroutine
plugins: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | |||||||||||
| 56 | =head2 fetch_proxies(&) | ||||||||||
| 57 | |||||||||||
| 58 | Fetches proxies. In order to save memory proxies are not returned as a list, but are reported through a callback function one by one instead. | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub fetch_proxies(&) { | ||||||||
|
Subroutine
fetch_proxies: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 63 | 0 | my $callback = shift; | |||||||||
| 64 | 0 | $_->fetch($callback) for grep s/^/WWW::FreeProxy::/, plugins; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | 1; | |||||||||
| 68 | |||||||||||
| 69 | =head1 AUTHOR | ||||||||||
| 70 | |||||||||||
| 71 | Alexey Alexandrov, C<< <swined at cpan.org> >> | ||||||||||
| 72 | |||||||||||
| 73 | =head1 BUGS | ||||||||||
| 74 | |||||||||||
| 75 | Please report any bugs or feature requests to | ||||||||||
| 76 | C<bug-www-freeproxy at rt.cpan.org>, or through the web interface at | ||||||||||
| 77 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-FreeProxy>. | ||||||||||
| 78 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||
| 79 | your bug as I make changes. | ||||||||||
| 80 | |||||||||||
| 81 | =head1 SUPPORT | ||||||||||
| 82 | |||||||||||
| 83 | You can find documentation for this module with the perldoc command. | ||||||||||
| 84 | |||||||||||
| 85 | perldoc WWW::FreeProxy | ||||||||||
| 86 | |||||||||||
| 87 | You can also look for information at: | ||||||||||
| 88 | |||||||||||
| 89 | =over 4 | ||||||||||
| 90 | |||||||||||
| 91 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 92 | |||||||||||
| 93 | L<http://annocpan.org/dist/WWW-FreeProxy> | ||||||||||
| 94 | |||||||||||
| 95 | =item * CPAN Ratings | ||||||||||
| 96 | |||||||||||
| 97 | L<http://cpanratings.perl.org/d/WWW-FreeProxy> | ||||||||||
| 98 | |||||||||||
| 99 | =item * RT: CPAN's request tracker | ||||||||||
| 100 | |||||||||||
| 101 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-FreeProxy> | ||||||||||
| 102 | |||||||||||
| 103 | =item * Search CPAN | ||||||||||
| 104 | |||||||||||
| 105 | L<http://search.cpan.org/dist/WWW-FreeProxy> | ||||||||||
| 106 | |||||||||||
| 107 | =back | ||||||||||
| 108 | |||||||||||
| 109 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 110 | |||||||||||
| 111 | Copyright 2008 Alexey Alexandrov, all rights reserved. | ||||||||||
| 112 | |||||||||||
| 113 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 114 | under the same terms as Perl itself. | ||||||||||
| 115 | |||||||||||
| 116 | =cut | ||||||||||