X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fqrz.pl;h=910b1997d9fd94e662030cd75d3aac89e80f9915;hb=ad09cf7c29d54881a3e1bb4b8e5da30c2f58c4b6;hp=51a63c41afd3521fbb1e7291dde0a2066589ff01;hpb=575a26ea68a641f895f68ed28391962d92bf1912;p=spider.git diff --git a/cmd/show/qrz.pl b/cmd/show/qrz.pl index 51a63c41..910b1997 100644 --- a/cmd/show/qrz.pl +++ b/cmd/show/qrz.pl @@ -1,5 +1,5 @@ # -# Query the PineKnot Database server for a callsign +# Query the QRZ Database server for a callsign # # from an idea by Steve Franke K9AN and information from Angel EA7WA # @@ -8,41 +8,38 @@ my ($self, $line) = @_; my @list = split /\s+/, $line; # generate a list of callsigns my $l; +my $call = $self->call; my @out; +return (1, $self->msg('e24')) unless $Internet::allow; return (1, "SHOW/QRZ , e.g. SH/QRZ g1tlh") unless @list; use Net::Telnet; my $t = new Net::Telnet; -push @out, $self->msg('call1', "QRZ.com"); foreach $l (@list) { $t->open(Host => "qrz.com", Port => 80, - Timeout => 5); + Timeout => 15); if ($t) { - $t->print("GET /database?callsign=$l HTTP/1.0\n\n"); - Log('call', "show/qrz $l"); - my $state = "call"; + my $s = "GET /dxcluster.cgi?callsign=$l\&uid=$Internet::qrz_uid\&pw=$Internet::qrz_pw HTTP/1.0\n\n"; +# print $s; + $t->print($s); + Log('call', "$call: show/qrz \U$l"); + my $state = "blank"; while (my $result = $t->getline) { -# print "$state: $result"; - if ($state eq 'call' && $result =~ /$l/i) { - $state = 'getaddr'; - push @out, uc $l; - } elsif ($state eq 'getaddr' || $state eq 'inaddr') { - if ($result =~ /^\s+([\w\s.,;:-]+)(?:
)?$/) { - my $line = $1; - unless ($line =~ /^\s+$/) { - push @out, $line; - $state = 'inaddr' unless $state eq 'inaddr'; - } - } else { - $state = 'runout' if $state eq 'inaddr'; - } +# print $result; + if ($state eq 'blank' && $result =~ /^\s*Callsign\s*:/i) { + $state = 'go'; + } elsif ($state eq 'go') { + next if $result =~ /^\s*Usage\s*:/i; + chomp $result; + push @out, $result; } } $t->close; + push @out, $self->msg('e3', 'qrz.com', uc $l) unless @out; } else { push @out, $self->msg('e18', 'QRZ.com'); }