IPwhois查询源码


<?php
$ip = $_REQUEST['ip'];
 $curl  =  curl_init ( ) ;
curl_setopt ( $curl , CURLOPT_URL ,  'https://ipwhois.cnnic.cn/bns/query/Query/ipwhoisQuery.do?txtquery='.$ip.'&queryOption=ipv4' ) ;
     curl_setopt ( $curl , CURLOPT_RETURNTRANSFER ,  1 ) ;
     $data  =  curl_exec ( $curl ) ;
     curl_close ( $curl ) ;
    $mode = "/<table[^>]* [^>]*>(.*?) <\/table>/si";
    preg_match($mode,$data,$m);
   $newsj =  strip_tags($m[0]);

$str = preg_replace('/\s+/', '', $newsj);
$str = str_replace(":","&nbsp;",$str);
$arr = explode('&nbsp;', $str);

print_r($arr);
声明:本文为原创,作者为 温耀辉,转载时请保留本声明及附带文章链接:https://blog.wenyaohui.com/155.html