line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package USCIS::Case; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
85222
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @EXPORT_OK = qw(check_case_status); |
7
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
8
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
125
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
445
|
use LWP::Protocol::https; |
|
1
|
|
|
|
|
104087
|
|
|
1
|
|
|
|
|
40
|
|
13
|
1
|
|
|
1
|
|
570
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
12085
|
|
|
1
|
|
|
|
|
28
|
|
14
|
1
|
|
|
1
|
|
567
|
use XML::LibXML; |
|
1
|
|
|
|
|
44576
|
|
|
1
|
|
|
|
|
16
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub check_case_status { |
18
|
0
|
|
|
0
|
1
|
|
my $case_number = shift @_; |
19
|
0
|
|
|
|
|
|
my $case_status_ref = { |
20
|
|
|
|
|
|
|
'validity' => 'no', |
21
|
|
|
|
|
|
|
'case_number' => $case_number, |
22
|
|
|
|
|
|
|
'case_status' => undef, |
23
|
|
|
|
|
|
|
'case_detail' => undef, |
24
|
|
|
|
|
|
|
'uscis_web_rc' => '', |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# USCSI case status query vars |
28
|
0
|
|
|
|
|
|
my $uscis_case_status_endpoint = 'https://egov.uscis.gov/casestatus/mycasestatus.do'; |
29
|
0
|
|
|
|
|
|
my $query_form = [ |
30
|
|
|
|
|
|
|
'appReceiptNum' => $case_number, |
31
|
|
|
|
|
|
|
'initCaseSearch' => 'CHECK STATUS', |
32
|
|
|
|
|
|
|
'changeLocale' => '', |
33
|
|
|
|
|
|
|
]; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# construct UA to call USCIS case status endpoint |
36
|
0
|
|
|
|
|
|
my $call = LWP::UserAgent->new(); |
37
|
0
|
|
|
|
|
|
my $res = $call->post($uscis_case_status_endpoint, Content => $query_form); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# update USCIS web access response code / messages |
40
|
0
|
|
|
|
|
|
$case_status_ref->{uscis_web_rc} = $res->status_line; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
43
|
0
|
|
|
|
|
|
my $case_status_html = $res->content; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $dom = XML::LibXML->load_html( |
46
|
|
|
|
|
|
|
string => $case_status_html, |
47
|
|
|
|
|
|
|
recover => 1, |
48
|
|
|
|
|
|
|
suppress_errors => 1, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# XPath search |
52
|
0
|
|
|
|
|
|
my $case_status = ($dom->findnodes('//div[@class=\'rows text-center\']/h1')->to_literal_list)[0]; |
53
|
0
|
|
|
|
|
|
my $case_detail = ($dom->findnodes('//div[@class=\'rows text-center\']/p')->to_literal_list)[0]; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if (defined($case_status)) { |
56
|
0
|
|
|
|
|
|
$case_status_ref->{validity} = 'yes'; |
57
|
0
|
|
|
|
|
|
$case_status_ref->{case_status} = $case_status; |
58
|
0
|
|
|
|
|
|
$case_status_ref->{case_detail} = $case_detail; |
59
|
|
|
|
|
|
|
} else { |
60
|
0
|
|
|
|
|
|
$case_status_ref->{validity} = 'no'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $case_status_ref; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |