CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
parses QRZ.com

 



macuser9214
Novice

Sep 25, 2007, 8:27 PM

Post #1 of 1 (1444 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.



Code
#!/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/\&nbsp;//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.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives