【问题标题】:How to check a domain age using php如何使用php检查域年龄
【发布时间】:2012-01-18 06:13:06
【问题描述】:

您好,我想知道是否有一种很好的方法可以找出特定域的年龄。

但我想找到一种方法来以编程方式要求 DNS 使用 php 而不是从在线工具检查域年龄。

我正在互联网上搜索以了解 google 如何检查我的域名年龄和其他 SEO 工具。

对于必须具有特殊权限才能询问域年龄的域,此信息是否为私有?如果是的话?谷歌怎么知道我的域名年龄?没有人问我的域名年龄.. 他们怎么知道?

【问题讨论】:

标签: php networking dns


【解决方案1】:

你想要WHOIS,最近在RFC3912中定义:

$ whois stackoverflow.com

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

   Domain Name: STACKOVERFLOW.COM
   Registrar: GODADDY.COM, INC.
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com
   Name Server: NS1.SERVERFAULT.COM
   Name Server: NS2.SERVERFAULT.COM
   Name Server: NS3.SERVERFAULT.COM
   Status: clientDeleteProhibited
   Status: clientRenewProhibited
   Status: clientTransferProhibited
   Status: clientUpdateProhibited
   Updated Date: 30-nov-2010
   Creation Date: 26-dec-2003
   Expiration Date: 26-dec-2014
   
   [...]

【讨论】:

    【解决方案2】:

    您正在寻找Whois 服务。

    PHPWhois:用于whois查询的PHP类,可以查询正确的whois服务器的域名、ip地址和AS句柄,并以结构化数组的形式返回数据。

    【讨论】:

      【解决方案3】:

      您是在寻找 php 脚本还是网络服务?

      如果是网络服务,请查看此bulk domain age checker 工具,它可以让您找出域注册日期和到期日期以及注册商名称。您可以一次批量检查 500 个域。

      希望有帮助

      【讨论】:

        【解决方案4】:

        大多数 TLD 的注册日期可通过 WHOIS 获得,并且不在 DNS 中。

        对于 com/net 域,您可以查看 whois.internic.net 以获取“创建日期”。对于大多数国家 TLD,您可以通过“country-code.whois-servers.net”的 DNS 查询找到 WHOIS 服务器。大多数 BSD 和 Linux 变体中的命令行 WHOIS 客户端会自动查找合适的 WHOIS 服务器。

        请注意,每个注册商都有自己的格式来呈现此信息,并且大多数注册商都在其 WHOIS 服务器上实施了控制,以限制来自同一 IP 地址的频繁请求。

        看看PHPWhois

        【讨论】:

        • 当我执行 whois 命令时,我在问谁? dns?还是其他服务?
        • 您在询问 WHOIS 服务器。 WHOIS 是它自己的协议,在 TCP 端口 43 上运行,就像 HTTP 在 tcp 端口 80 上运行一样,DNS 在 udp 端口​​ 53 上运行。命令行中的 WHOIS 程序是该协议的客户端,就像 Firefox 是 HTTP 客户端一样。您的客户端与服务器建立连接,发出请求,然后为您解释和/或显示结果。
        • 对于大多数 whois 客户端已经知道的特定顶级域,在哪里可以找到合适的 whois 服务器有一些规则。查看whois man page 了解更多信息。此外,有关出色的基于 Web 的 whois 选项,请查看 Uwhois.com
        【解决方案5】:

        使用这个 PHP 脚本检查域名年龄,在这里你可以找到工作 domain age checker

        class DomainAge{
        
          private $WHOIS_SERVERS=array(
        
          "com"=>array("whois.verisign-grs.com","/Creation Date:(.*)/"),
        
          "net"=>array("whois.verisign-grs.com","/Creation Date:(.*)/"),
        
          "org"=>array("whois.pir.org","/Created On:(.*)/"),
        
          "info"=>array("whois.afilias.info","/Created On:(.*)/"),
        
          "biz"=>array("whois.neulevel.biz","/Domain Registration Date:(.*)/"),
        
          "us"=>array("whois.nic.us","/Domain Registration Date:(.*)/"),
        
          "uk"=>array("whois.nic.uk","/Registered on:(.*)/"),
        
          "ca"=>array("whois.cira.ca","/Creation date:(.*)/"),
        
          "tel"=>array("whois.nic.tel","/Domain Registration Date:(.*)/"),
        
          "ie"=>array("whois.iedr.ie","/registration:(.*)/"),
        
          "it"=>array("whois.nic.it","/Created:(.*)/"),
        
          "cc"=>array("whois.nic.cc","/Creation Date:(.*)/"),
        
          "ws"=>array("whois.nic.ws","/Domain Created:(.*)/"),
        
          "sc"=>array("whois2.afilias-grs.net","/Created On:(.*)/"),
        
          "mobi"=>array("whois.dotmobiregistry.net","/Created On:(.*)/"),
        
          "pro"=>array("whois.registrypro.pro","/Created On:(.*)/"),
        
          "edu"=>array("whois.educause.net","/Domain record activated:(.*)/"),
        
          "tv"=>array("whois.nic.tv","/Creation Date:(.*)/"),
        
          "travel"=>array("whois.nic.travel","/Domain Registration Date:(.*)/"),
        
          "in"=>array("whois.inregistry.net","/Created On:(.*)/"),
        
          "me"=>array("whois.nic.me","/Domain Create Date:(.*)/"),
        
          "cn"=>array("whois.cnnic.cn","/Registration Date:(.*)/"),
        
          "asia"=>array("whois.nic.asia","/Domain Create Date:(.*)/"),
        
          "ro"=>array("whois.rotld.ro","/Registered On:(.*)/"),
        
          "aero"=> array("whois.aero","/Created On:(.*)/"),
        
          "nu"=> array("whois.nic.nu","/created:(.*)/")
          );
        
          public function age($domain)
          {
        
          $domain = trim($domain);
        
          if(substr(strtolower($domain), 0, 7) == "http://") 
        
          $domain = substr($domain, 7); // remove http:// if included
        
          if(substr(strtolower($domain), 0, 4) == "www.") 
        
           $domain = substr($domain, 4);//remove www from domain
        
          if(preg_match("/^([-a-z0-9]{2,100}).([a-z.]{2,8})$/i",$domain))
          {
        
          $domain_parts = explode(".", $domain);
        
          $tld = strtolower(array_pop($domain_parts));
        
          if(!$server=$this->WHOIS_SERVERS[$tld][0]) {
        
          return false;
        
          }
        
          $res=$this->queryWhois($server,$domain);
        
          if(preg_match($this->WHOIS_SERVERS[$tld][1],$res,$match))
        
          {
        
          date_default_timezone_set('UTC');
        
          $time = time() - strtotime($match[1]);
        
          $years = floor($time / 31556926);
        
          $days = floor(($time % 31556926) / 86400);
        
          if($years == "1") {$y= "1 year";
        
        }
          else 
        
        {
        $y = $years . " years";
        }
          if($days == "1") {$d = "1 day";
        }
          else 
        {
        $d = $days . " days";
        }
          return "$y, $d";
        
         }
          else
        
          return false;
        }
          else
        
          return false;
        
        }
        
          private function queryWhois($server,$domain)
        
          {
        
          $fp = @fsockopen($server, 43, $errno, $errstr, 20) or die("Socket Error " 
          . $errno . " - " . $errstr);
        
        if($server=="whois.verisign-grs.com")
        
        $domain="=".$domain;
        
          fputs($fp, $domain . "rn");
          $out = "";
        
          while(!feof($fp)){
        
          $out .= fgets($fp);
        
          }
          fclose($fp);
        
          return $out;
          }
        
        }
        

        【讨论】:

        • 直到我在 fputs 命令末尾附近的“r”和“n”之前添加反斜杠之前,该类对我不起作用。 fputs($fp, $domain . "\r\n"); 然后效果很好!
        • @AamishSohail, 你能重新检查一下这个 URL seotablets.com/domain-age-checker
        猜你喜欢
        • 2012-12-15
        • 1970-01-01
        • 2011-05-15
        • 1970-01-01
        • 2021-06-29
        • 2013-06-20
        • 1970-01-01
        • 2019-04-24
        • 1970-01-01
        相关资源
        最近更新 更多