
macuser9214
Novice
Sep 25, 2007, 8:27 PM
Post #1 of 1
(1280 views)
|
|
parses QRZ.com
|
Can't Post
|
|
Don't think anyone has requested this yet, but it parses the QRZ.com callsign database. My first TK program, so might be rough.
#!/usr/bin/perl use Tk; use LWP::Simple; use LWP::UserAgent; my $main = MainWindow -> new(); $entry = $main -> Entry(-textvariable => \$callsign); $entry -> pack; $main->Button(-text => 'Look Up', -command => sub{display($entry)} )->pack; my $text1 = $main->Text ('-width' => 30, '-height' => 15, '-background' => 'Grey',)-> pack; $main->Button(-text => 'Stop', -command => [$main => 'destroy'])->pack; sub display { my ($widget) = @_; my $entered = $widget -> get(); $call = $callsign; $ua = LWP::UserAgent->new(); $request = HTTP::Request->new('GET', "http://www.qrz.com/detail/$call"); $response = $ua->request($request); $qrz = $response->content; $qrz =~ m#Name</td><td class="q2"><b>(.*?)</b>#i; my $name = $1; $qrz =~ m#Addr1</td><td class="q2"><b>(.*?)</b>#i; my $addr1 = $1; $qrz =~ m#Addr2</td><td class="q2"><b>(.*?)</b>#i; my $addr2 = $1; $qrz =~ m#Country</td><td class="q2"><b>(.*?)</b>#i; my $country = $1; $qrz =~ m#Class:<b>(.*?)</b>#i; my $class = $1; $class =~ s/\ //g; $class =~ s/^\s+//g; $class =~ s/\s+$//g; $text1->insert('end', "$name\n$class\n$addr1\n$addr2\n$country\n\n"); } MainLoop; Please consider visiting my site, at <a href="http://macuser9214.com"> macuser9214.com - Thought's Blog/Tech Forum.
|