SoFunction
Updated on 2025-04-07

Perl batch query method code for IP home


#!/usr/bin/perl
use IP::QQWry::Decoded;
use Encode;
use utf8;
binmode(STDIN, ':encoding(utf8)');   #These three lines
binmode(STDOUT, ':encoding(utf8)');   #Copy someone else's
binmode(STDERR, ':encoding(utf8)'); # Used to output Chinese, and search for Chinese
my $qqwry=IP::QQWry::Decoded->new('','gbk');
open UNUSE,'';
while (<UNUSE>){
        ($id,$ip,$key)=/(\d+)\s+(.*?)\s+(.*)/;
my $info=$qqwry->query("$ip");    #In fact, the key code is just this line, haha
printf "%s\t%s\t%s\n",$id,$ip,$key if $info=~/region name/;
}