chitownclone
Programmer
I am using the following methods to collect IP and server data for a large number (500k+) urls, which is then inserted into a MySQL database.
I need:
- IP
- DNS Server Name
- Server Info (Type and OS)
Is there a more efficient method to collect this data? Is it redundant to use 3 modules..ie can this data be collected with 1 or 2?
Any suggestions would be hugely appreciated.
-- Thanks
I need:
- IP
- DNS Server Name
- Server Info (Type and OS)
Is there a more efficient method to collect this data? Is it redundant to use 3 modules..ie can this data be collected with 1 or 2?
Any suggestions would be hugely appreciated.
-- Thanks
Code:
# ######## IP PING ##########
$p = Net::Ping->new("syn");
$p->{port_num} = getservbyname("http", "tcp");
$p->ping($url);
($host,$rtt,$ip) = $p->ack;
$p->close();
($ip1, $ip2, $ip3,$ip4) = split /\./, $ip, 4;
# ######## DNS Name Grab ##########
$res = Net::DNS::Resolver->new;
$query = $res->query("$ip", "PTR");
if ($query) {
foreach $rr (grep { $_->type eq 'PTR' } $query>answer) {
$ptrname = $rr->ptrdname;
}
}
# ######## Server Data Grab ##########
$robot = new LWP::UserAgent;
$robot->timeout (4);
$request = new HTTP::Request GET => $url;
$response = $robot->request( $request );
@data = $response->content . "\n";
if ($response->is_success) {
$server=$response->server;
}