กรุณาปิด AdBlock!

Cancel your adBlock please.

ขยายหน้าเว็บRegister Login
 โฆษณา
หน้า: [1]  ลงล่าง
  พิมพ์  
topic

[Perl] IP Information : GUI  (อ่าน 5055 ครั้ง)

ไอที
« เมื่อ: 16, 04 2012, 01:56:44 AM »
SS :


หัดเขียนอีกเช่นเคยครับ ยังมึนๆอยู่ while ซ้อน while - -" เขียนได้เท่านี้แหละครับ ถ้าใครมีวิธีทำให้เร็วหรือดีกว่านี้กบอกหน่อยนะครับ ^^"

โค๊ด:
#!/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/<span style=\"font-size:12px;\">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/<td class=\'columresult\'>ISP<\/td><td align=\'left\'><b>(.*?)&nbsp;<\/b>/g);
print "ISP : $1 \n";
my ($city) = ($content =~ m/City<\/td><td align=\'left\'><b>(.*?)<\/b>/g);
print "City : $1 \n";
my ($state) = ($content =~ m/State or Region<\/td><td align=\'left\'><b>(.*?)<\/b>/g);
print "State or Region : $1 \n";
my ($country) = ($content =~ m/Country<\/td><td align=\'left\'><b>(.*?)<\/b>/g);
print "Country : $1 \n";
my ($la1,$la2) = ($content =~ m/Latitude & Longitude<\/td><td align=\'left\'><b>(.*?)&nbsp;&nbsp;(.*?)<\/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;

ปล. ขอบคุณ PongZ มากๆครับที่แก้ไขโค้ดให้ ^^
ที่มา : http://www.sornram9254.com/blog/perl-ip-information-gui link
sornram9254
เด็กไอทีคลับหน้าใหม่
*
พลังความคิด 4
กระทู้: 20
เว็บไซต์
บันทึกการเข้า

link link link
link link link
link link link
link link
link link
link
หน้า: [1]  ขึ้นบน
  พิมพ์  
 
กระโดดไป: