[Perl] IP Information : GUI
SS :
#!/usr//bin/perl
#########################################################################
# ░░░░░░░░░░░░▄▄░░░░░░░░░░░░░░ Copyright (c) 2012 by sornram9254.com
# ░░░░░░░░░░░█░░█░░░░░░░░░░░░░
# ░░░░░░░░░░░█░░█░░░░░░░░░░░░░ This software is open source,
# ░░░░░░░░░░█░░░█░░░░░░░░░░░░░ licensed under the GNU/GPL,v3.0
# ░░░░░░░░░█░░░░█░░░░░░░░░░░░░
# ██████▄▄█░░░░░██████▄░░░░░░░ Basically,
# ▓▓▓▓▓▓█░░░░░░░░░░░░░░█░░░░░░ this means that you're allowed to modify and
# ▓▓▓▓▓▓█░░░░░░░░░░░░░░█░░░░░░ distribute this software.
# ▓▓▓▓▓▓█░░░░░░░░░░░░░░█░░░░░░ However, if you distribute modified versions,
# ▓▓▓▓▓▓█░░░░░░░░░░░░░░█░░░░░░ you MUST also distribute the source code.
# ▓▓▓▓▓▓█░░░░░░░░░░░░░░█░░░░░░
# ▓▓▓▓▓▓█████░░░░░░░░░██░░░░░░ See http://www.gnu.org/licenses/gpl.html
# █████▀░░░░▀▀████████░░░░░░░░ for the full license.
#########################################################################
use Tk;
use LWP::Simple;
$mw = new MainWindow; $mw->title("Perl GUI :)"); $mw->geometry('200x70');
$mw->Label(-text => "IP Information")->pack;
$mw->Button(-text => "Check", -command => \&get_ip )->pack(-ipadx => 40,-ipady => 5);
sub get_ip {
my $ua = LWP::UserAgent->new();
my $contents = $ua->get('http://www.melissadata.com/lookups/iplocation.asp');
my $found = $contents->content;
while( $found =~ m/Your IP Address: (.*?)<\/span>/g ) {
$ip=$1;
print "IP : $1 \n";
$mw = new MainWindow; $mw->geometry('400x200'); $mw->title("Check IP : Result");
my $frm_name = $mw -> Frame() -> pack(); #New Frame
my $ent = $frm_name -> Entry(-text => "IP => $1") -> pack (-ipadx => 100,-ipady => 5);
#------------------------------------------------------------------------------------------------------------------------------------------
my $content = $ua->get('http://www.melissadata.com/lookups/iplocation.asp?ipaddress='.$ip)->content;
my ($isp) = ($content =~ m/ISP<\/td>(.*?) <\/b>/g);
print "ISP : $1 \n";
my ($city) = ($content =~ m/City<\/td>(.*?)<\/b>/g);
print "City : $1 \n";
my ($state) = ($content =~ m/State or Region<\/td>(.*?)<\/b>/g);
print "State or Region : $1 \n";
my ($country) = ($content =~ m/Country<\/td>(.*?)<\/b>/g);
print "Country : $1 \n";
my ($la1,$la2) = ($content =~ m/Latitude & Longitude<\/td>(.*?) (.*?)<\/b>/g);
print "Latitude : $1 .::.::. Longitude : $2 \n";
my $ent = $frm_name -> Entry(-text => "ISP => $isp") -> pack (-ipadx => 100,-ipady => 5);
my $ent = $frm_name -> Entry(-text => "City => $city") -> pack (-ipadx => 100,-ipady => 5);
my $ent = $frm_name -> Entry(-text => "State or Region => $state") -> pack (-ipadx => 100,-ipady => 5);
my $ent = $frm_name -> Entry(-text => "Country => $country") -> pack (-ipadx => 100,-ipady => 5);
my $ent = $frm_name -> Entry(-text => "Latitude => $la1 .::. Longitude => $la2") -> pack (-ipadx => 100,-ipady => 5);
#------------------------------------------------------------------------------------------------------------------------------------------
}
}
MainLoop;