卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章11201本站已运行3223

PHP域名Whois查询API接口源码

PHP域名Whois查询APIUSB源码,USB数据来自于值班员工具的Whois的查询工具。

APIUSB代码

<?php
error_reporting(0);
header('charset=utf-8');
if (!empty($_GET['domain'])) {//判断与否存有get值
/*获取网页内容*/
$curl = curl_init();
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
$httpheader[] = "Referer:https://whois.chinaz.com";
$httpheader[] = "User-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176 MicroMessenger/4.3.2";
curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, 'https://whois.chinaz.com/' . str_replace(array("https://", "https://"), "", $_GET['domain']));//去除https://和https://
$text = curl_exec($curl);
curl_close($curl);
/*对以获取的网页内容截取*/
preg_match('/登记注册商
(.*?)/i', $text, $zhuceshang); preg_match('/联系人
(.*?)/i', $text, $contacts); preg_match('/建立时间
(.*?)/i', $text, $chuangjianshijian); preg_match('/过期时间(.*?)/i', $text, $guoqishijian); preg_match('/DNS(.*?)
/i', $text, $dns); preg_match('/联系电话(.*?)/i', $text, $phone); preg_match('/公司(.*?)/i', $text, $gongsi); preg_match('/联系邮箱(.*?)/i', $text, $mail); $dnsarray = explode("
", $dns[1]); //对多个dns分组 /*对几个可能将为空的值推论*/ if (!empty($gongsi[1])) { $gongsi = $gongsi[1]; } else { $gongsi = '-'; } if (!empty($phone[1])) { $phone = $phone[1]; } else { $phone = '-'; } if (!empty($zhuceshang[1])) { $zhuceshang = $zhuceshang[1]; } else { $zhuceshang = '-'; } /*输入并完结程序*/ exit('

注册商:' . $zhuceshang . '

联系人:' . $contacts[1] . '

公司:' . $gongsi . '

邮箱:' . $mail[1] . '

电话:' . $phone . '

建立时间:' . $chuangjianshijian[1] . '

过期时间:' . $guoqishijian[1] . '

DNS:' . "$dnsarray[0]t$dnsarray[1]" . '

'); } else { //如果get值空则表明'Error'并结束程序 exit('请填写域名'); }

API接口采用方法:网站/USB名称.php/?domain=这这里是要查询的域名

卓越飞翔博客
上一篇: 京东图床上传api接口源码
下一篇: 随机二次元图片API接口源码
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏