(.+?)\<\/tr\>/gs;
foreach my $row (@rows) {
$row =~ s/\n//g;
next if ($row !~ /\(.*?)\<\/td\>/g;
if (defined $path) {
next if ($path =~ /\.\./);
($link, $linkDesc) = $path =~ /^\(\w+)\/\<\/a\>$/;
if (defined $link) {
if ($type eq 'Directory') {
$type = 1;
}
else {
$type = 0;
}
my $item = {
DATE => $date,
isDIR => $type,
LINK => $link,
DESCRIPTION => $linkDesc
};
push $items, $item;
}
}
}
print Dumper $items;
return $items
}
sub sendGETrequest {
my $class = shift;
my $url = shift;
my $getRequest = HTTP::Request->new(GET => $url);
$getRequest->push_header('Accept-Encoding' => 'gzip, deflate');
$getRequest->push_header('Connection' => 'keep-alive');
$getRequest->push_header('Accept' => 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*');
$getRequest->push_header('Cookie' => $class->{COOKIE}) unless ($class->{COOKIE} eq '');
my $response = $ua->request($getRequest);
return $response;
}
sub sendPOSTrequest {
my $class = shift;
my $url = shift;
my $postData = shift;
my $postRequest = HTTP::Request->new(POST => $url);
$postRequest->content_type('application/x-www-form-urlencoded');
$postRequest->push_header('Accept-Encoding' => 'gzip, deflate');
$postRequest->push_header('Connection' => 'keep-alive');
$postRequest->push_header('Accept' => 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*');
$postRequest->content($postData);
my $response = $ua->request($postRequest);
return $response;
}
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->{COOKIE} = '';
return $self;
}
1;
|