#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
my $req = HTTP::Request->new(GET => 'http://192.168.0.1/Status.htm');
$req->authorization_basic('admin','hoge');
my $response = $ua->request($req);
if ($response->is_success){
my $data = $response->content;
$data=~s/<.*?>//g;
$data=~s/\ //g;
$data=~/IP.+?(\d{1,3}[\.\d]+)\s/;
print $1,"\n";
}
else {
die $response->status_line;
}
perlでルーターからWAN側のIPアドレスを取得してみる
このときに対象にしたルーターはNP-BBRM