line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::AntiCaptcha; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
71597
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
29
|
use 5.008_005; |
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
8
|
1
|
|
|
1
|
|
784
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
49151
|
|
|
1
|
|
|
|
|
37
|
|
9
|
1
|
|
|
1
|
|
9
|
use URI; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
533
|
use MIME::Base64; |
|
1
|
|
|
|
|
696
|
|
|
1
|
|
|
|
|
58
|
|
11
|
1
|
|
|
1
|
|
763
|
use JSON; |
|
1
|
|
|
|
|
10668
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
159
|
use vars qw/$errstr/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
393
|
|
14
|
0
|
|
|
0
|
0
|
|
sub errstr { $errstr } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
18
|
0
|
0
|
|
|
|
|
my %args = @_ % 2 ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
$args{clientKey} or croak "clientKey is required.\n"; |
21
|
0
|
|
0
|
|
|
|
$args{ua} ||= LWP::UserAgent->new; |
22
|
0
|
|
0
|
|
|
|
$args{url} ||= 'https://api.anti-captcha.com/'; |
23
|
0
|
|
0
|
|
|
|
$args{sleep} ||= 3; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return bless \%args, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub createTask { |
29
|
0
|
|
|
0
|
1
|
|
my ($self, $task, $softId, $languagePool) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
$self->request('createTask', |
|
|
0
|
|
|
|
|
|
32
|
|
|
|
|
|
|
task => $task, |
33
|
|
|
|
|
|
|
$softId ? (softId => $softId) : (), |
34
|
|
|
|
|
|
|
$languagePool ? (languagePool => $languagePool) : (), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub getTaskResult { |
39
|
0
|
|
|
0
|
1
|
|
my ($self, $taskId) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->request('getTaskResult', taskId => $taskId); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub getBalance { |
45
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self->request('getBalance'); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub getQueueStats { |
51
|
0
|
|
|
0
|
1
|
|
my ($self, $queueId) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->request('getQueueStats', queueId => $queueId); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub reportIncorrectImageCaptcha { |
57
|
0
|
|
|
0
|
1
|
|
my ($self, $taskId) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$self->request('reportIncorrectImageCaptcha', taskId => $taskId); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub request { |
63
|
0
|
|
|
0
|
0
|
|
my ($self, $url, %params) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$params{clientKey} = $self->{clientKey}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $res = $self->{ua}->post($self->{url} . $url, |
68
|
|
|
|
|
|
|
'Accept' => 'application/json', |
69
|
|
|
|
|
|
|
'Content-Type' => 'application/json', |
70
|
|
|
|
|
|
|
'Content' => encode_json(\%params), |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# print Dumper(\$res); use Data::Dumper; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
unless ($res->is_success) { |
76
|
0
|
|
|
|
|
|
$errstr = "Failed to post $url: " . $res->status_line; |
77
|
0
|
|
|
|
|
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
|
return decode_json($res->decoded_content); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |