+25Nov09=======================================================================
+1. Change sh/qrz to use the xml interface. You will have to subscribe to
+the xml interface - see http://www.qrz.com/XML/index.html for more info.
+2. Remove (bodged) forced encoding to iso-8859 on incoming text. More
+subtle handling will be required.
14Nov09=======================================================================
1. Add CTY-1921 prefixes
2. allow -SSID values on set/badnode
# Query the QRZ Database server for a callsign
#
# from an idea by Steve Franke K9AN and information from Angel EA7WA
+# and finally (!) modified to use the XML interface
#
-# Copyright (c) 2001 Dirk Koopman G1TLH
-#
-#
+# Copyright (c) 2001-2009 Dirk Koopman G1TLH
#
my ($self, $line) = @_;
my @list = split /\s+/, $line; # generate a list of callsigns
return (1, $self->msg('e24')) unless $Internet::allow;
return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless @list;
-#my $target = $Internet::http_proxy || 'www.qrz.com';
-#my $port = $Internet::http_proxy_port || 80;
-#my $url = '';
-#$url = 'http://www.qrz.com' if $Internet::http_proxy;
-my $target = $Internet::http_proxy || $Internet::qrz_url || 'www.qrz.com';
+my $target = $Internet::http_proxy || $Internet::qrz_url || 'xml.qrz.com';
my $port = $Internet::http_proxy_port || 80;
my $url = '';
-$url = 'http://' . ($Internet::qrz_url | 'www.qrz.com') if $Internet::http_proxy;
+$url = 'http://' . ($Internet::qrz_url | 'xml.qrz.com') if $Internet::http_proxy;
use Net::Telnet;
if (!$t || $@) {
push @out, $self->msg('e18', 'QRZ.com');
} else {
- my $s = "GET $url/p/dxcluster.pl?callsign=$l\&username=$Internet::qrz_uid\&password=$Internet::qrz_pw HTTP/1.0\n\n";
+ my $s = "GET /xml?callsign=$l;username=$Internet::qrz_uid;password=$Internet::qrz_pw;agent=dxspider HTTP/1.0\n\n";
dbg($s) if isdbg('qrz');
$t->print($s);
Log('call', "$call: show/qrz \U$l");
push @out, $self->msg('e18', 'QRZ.com');
last;
}
- if ($state eq 'blank' && $result =~ /^\s*Callsign\s*:/i) {
+ if ($state eq 'blank' && $result =~ /^<Callsign>/i) {
$state = 'go';
} elsif ($state eq 'go') {
- next if $result =~ /^\s*Usage\s*:/i;
- chomp $result;
- push @out, $result;
+ next if $result =~ m|<user>|;
+ next if $result =~ m|<u_views>|;
+ next if $result =~ m|<locref>|;
+ next if $result =~ m|<ccode>|;
+ next if $result =~ m|<dxcc>|;
+ last if $result =~ m|</Callsign>|;
+ my ($tag, $data) = $result =~ m|^\s*<(\w+)>(.*)</|;
+ push @out, sprintf "%10s: $data", $tag;
}
}
$t->close;
chomp $text;
unpad($text);
$text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
- $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
+# $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
$text =~ s/[^\#a-zA-Z0-9]//g;
$text = substr($text, 0, $duplth) if length $text > $duplth;
my $dupkey = "A$call|$to|\L$text";
}
}
my $otext = $text;
- $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
+# $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
$text =~ s/^\+\w+\s*//; # remove leading LoTW callsign
$text =~ s/\s{2,}[\dA-Z]?[A-Z]\d?$// if length $text > 24;
$text =~ s/[\W\x00-\x2F\x7B-\xFF]//g; # tautology, just to make quite sure!