2 # Query the QRZ Database server for a callsign
4 # from an idea by Steve Franke K9AN and information from Angel EA7WA
5 # and finally (!) modified to use the XML interface
7 # Copyright (c) 2001-2009 Dirk Koopman G1TLH
9 my ($self, $line) = @_;
10 my @list = split /\s+/, $line; # generate a list of callsigns
12 my $call = $self->call;
15 return (1, $self->msg('e24')) unless $Internet::allow;
16 return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless @list;
17 my $target = $Internet::http_proxy || $Internet::qrz_url || 'xml.qrz.com';
18 my $port = $Internet::http_proxy_port || 80;
20 $url = 'http://' . ($Internet::qrz_url | 'xml.qrz.com') if $Internet::http_proxy;
25 my $t = new Net::Telnet;
29 $t->open(Host => $target,
35 push @out, $self->msg('e18', 'QRZ.com');
37 my $s = "GET /xml?callsign=$l;username=$Internet::qrz_uid;password=$Internet::qrz_pw;agent=dxspider HTTP/1.0\n\n";
38 dbg($s) if isdbg('qrz');
40 Log('call', "$call: show/qrz \U$l");
42 while (my $result = eval { $t->getline(Timeout => 30) } || $@) {
43 dbg($result) if isdbg('qrz') && $result;
45 push @out, $self->msg('e18', 'QRZ.com');
48 if ($state eq 'blank' && $result =~ /^<Callsign>/i) {
50 } elsif ($state eq 'go') {
51 next if $result =~ m|<user>|;
52 next if $result =~ m|<u_views>|;
53 next if $result =~ m|<locref>|;
54 next if $result =~ m|<ccode>|;
55 next if $result =~ m|<dxcc>|;
56 last if $result =~ m|</Callsign>|;
57 my ($tag, $data) = $result =~ m|^\s*<(\w+)>(.*)</|;
58 push @out, sprintf "%10s: $data", $tag;
62 push @out, $self->msg('e3', 'qrz.com', uc $l) unless @out;