#!/usr/bin/perl use DBI; use strict; use warnings; require LWP::UserAgent; use XML::Simple; #use Data::Dumper; use Date::Calc qw(Delta_DHMS Time_to_Date); use Class::Date qw(date); my $db = "CAMDPAMS"; my $host = "192.168.8.10"; my $sth; my $sth1; my $sql; my $dbh = DBI ->connect("dbi:Pg:dbname=$db;host=$host","olegk","4Q2073gl",{AutoCommit=>1,RaiseError=>1,ChopBlanks=>1}); my @res; $sql = "select \"SiteURL\",\"SiteId\" from \"WhiteListing\".\"Sites\" where \"LabStatus\" in('6','8','9')"; $sth=$dbh->prepare($sql); $sth->execute; if($sth->rows>0){ while(my @r=$sth->fetchrow_array){ $dbh->do("select * from \"WhiteListing\".\"Update_crawlerstat\"('$res[0]', $r[1])"); $sth=$dbh->prepare("select * from \"WhiteListing\".check_sha1_by_site($r[1])"); $sth->execute; my $cnt = $sth->fetchrow_array; $sth->finish; if($cnt>0){ if(send_to_crawler($r[0])=~/insert successfully/){ $dbh->do("select * from \"WhiteListing\".\"Update_labstatus\"(3, $r[1],24)");} my $result = get_crawler($r[0]); if($result ne "NOTFOUND"){ $dbh->do("select * from \"WhiteListing\".\"Update_crawlerstat\"('$result', $r[1])");} } } } $sth->finish; #$dbh->commit; $dbh->disconnect; ########### sub send_to_crawler{ my $url = shift; my $ua = LWP::UserAgent->new; my $xml = new XML::Simple; $ua->timeout(10); $ua->env_proxy; my $response= $ua->get("http://192.168.158.162:8083/axis2/services/malwareService/insertCrawlerUrl?url=$url&type=white"); if ($response->is_success) { my $data =$xml->XMLin($response->decoded_content); return $data->{'ns:return'}; } else { return "NOTINSERT"; } } ########### sub get_crawler { my $url = shift; my $ua = LWP::UserAgent->new; my $xml = new XML::Simple; $ua->timeout(10); $ua->env_proxy; my $response= $ua->get("http://192.168.158.162:8083/axis2/services/malwareService/findCrawlerByUrl?url=$url"); if ($response->is_success) { my $data =$xml->XMLin($response->decoded_content); return "$data->{'ns:return'}->{'ax21:status'};$data->{'ns:return'}->{'ax21:updatedTime'}"; #print Dumper($data); } else {return "NOTFOUND";} }