App-geoip
view release on metacpan or search on metacpan
warn "Using GeoIP to determine own location\n";
$here = {};
my %cls = (
lat => "Latitude",
lng => "Longitude",
ip => "IP",
city => "City",
company => "Provider",
);
foreach my $url (qw( https://iplocation.com https://geoiptool.com )) {
my $rsp = $ua->request (HTTP::Request->new (GET => $url));
if ($rsp->is_success) {
$opt_v > 1 and warn "$url: OK\n";
my $tree = HTML::TreeBuilder->new ();
if ($tree->parse_content ($rsp->content)) {
foreach my $e ($tree->look_down (_tag => "div", class => "data-item")) {
my $di = $e->as_text or next;
$di =~ m/^\s*(\S[^:]+?)\s*:\s*(.*?)\s*$/ and $here->{$1} //= $2;
}
foreach my $e ($tree->look_down (_tag => "td",
class => qr{^(?:lat|lng|ip|city|company)$})) {
lib/App/geoip.pm view on Meta::CPAN
warn "Using GeoIP to determine own location\n";
$here = {};
my %cls = (
lat => "Latitude",
lng => "Longitude",
ip => "IP",
city => "City",
company => "Provider",
);
foreach my $url (qw( https://iplocation.com https://geoiptool.com )) {
my $rsp = $ua->request (HTTP::Request->new (GET => $url));
if ($rsp->is_success) {
$opt_v > 1 and warn "$url: OK\n";
my $tree = HTML::TreeBuilder->new ();
if ($tree->parse_content ($rsp->content)) {
foreach my $e ($tree->look_down (_tag => "div", class => "data-item")) {
my $di = $e->as_text or next;
$di =~ m/^\s*(\S[^:]+?)\s*:\s*(.*?)\s*$/ and $here->{$1} //= $2;
}
foreach my $e ($tree->look_down (_tag => "td",
class => qr{^(?:lat|lng|ip|city|company)$})) {
( run in 0.352 second using v1.01-cache-2.11-cpan-de7293f3b23 )