【问题标题】:PHP - How do I get name servers from domains via WhoIsPHP - 如何通过 WhoIs 从域中获取名称服务器
【发布时间】:2016-10-19 17:03:55
【问题描述】:

我有一个包含 300 个域的列表,我想为其获取名称服务器。

https://github.com/regru/php-whois

我指的是这个,但我是 php 新手,我不太确定我在哪里设置要检查的域列表。

我想最终得到一个 csv 文件,该文件具有: 域名,名称服务器,名称服务器,名称服务器

    <?php

$sld = 'reg.ru';

$domain = new Phois\Whois\Whois($sld);

$whois_answer = $domain->info();

echo $whois_answer;

if ($domain->isAvailable()) {
    echo "Domain is available\n";
} else {
    echo "Domain is registered\n";
}

【问题讨论】:

    标签: php dns nameservers


    【解决方案1】:

    我会做这样的事情来开始,你应该能够在之后循环

    <?php
    $domain = "google.com";
    $whois  = json_decode(file_get_contents("https://www.whoisxmlapi.com/whoisserver/WhoisService?domainName=".$domain."&outputFormat=json"), true);
    
    if(isset($whois["WhoisRecord"]["dataError"]) && $whois["WhoisRecord"]["dataError"]){
        echo $domain." is available\n";
    }else{
        echo $domain." is not available\nNameservers: ";
        var_dump($whois["WhoisRecord"]["nameServers"]["hostNames"]);
        echo "\n";
    }
    ?>
    

    【讨论】:

    • 您收到google.com is not available Nameservers: NULL 的结果了吗?
    • 我的域名服务器一直为空:s
    • php testNSLookup.php google.com 不可用域名服务器:array(4) { [0]=> string(14) "ns1.google.com" [1]=> string(14) "ns4.google.com" [2]=> 字符串(14) "ns3.google.com" [3]=> 字符串(14) "ns2.google.com" }
    • 您可能需要访问 www.whoisxmlapi.com 并获取 API 密钥。
    • 前 500 个查询是免费的,然后 2000 个/月是 15 美元。
    猜你喜欢
    • 2011-11-04
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 2010-12-08
    • 2016-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多