简体   繁体   中英

What is the most efficient way to convert a large db with ip addresses to countries without installing any database?

I want to find out how many visitors are from my country.

What is the most efficient way to convert a large db with ip addresses to countries without installing any database? Or is there any other solution?

I used this api but the server response is too long...

     foreach ($loc as $row) {
        $ip = $row->last_ip;

         $country = file_get_contents('http://api.hostip.info/country.php?ip='.$ip);
        if ($country == 'RO') {
            $num++;
        } 
     }

Can cURL help me with the server response problem? If yes, how can I use it?

I would go about testing Geo::IP which works pretty well.
http://metacpan.org/pod/Geo::IP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM