如何使用php检查域名年龄

xj3cbfub  于 2023-05-27  发布在  PHP
关注(0)|答案(6)|浏览(131)

你好,我想知道是否有一个很好的方法来找出一个特定域的年龄。
但我想找到一种方法来做到这一点编程要求DNS检查域年龄使用php,而不是从一个在线工具。
我在互联网上搜索,以了解谷歌是如何检查我的域名年龄和其他搜索引擎优化工具。
对于您必须具有特殊权限才能询问域年龄的域,此信息是否为私有?如果是呢?google怎么知道我的域名年龄?没有人问我的域名年龄..他们怎么会知道?

rlcwz9us

rlcwz9us1#

您需要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
   
   [...]
zpqajqem

zpqajqem2#

您正在查找Whois服务。
PHPWhois:PHP的whois查询类,可以查询正确的whois服务器的域名,ip地址和AS句柄,并返回一个结构化数组中的数据.

13z8s7eq

13z8s7eq3#

你是在找php脚本还是web服务?
如果是一个网络服务,那么看看这个bulk domain age checker工具,它可以让你找出域名注册日期和到期日期加上注册商名称。您可以一次批量检查500个域。
希望这对你有帮助

sigwle7e

sigwle7e4#

大多数TLD的注册日期可通过WHOIS获得,而不是在DNS中。
对于com/net域名,您可以查看whois.internic.net的“创建日期”。对于大多数国家/地区的TLD,您可以通过DNS查询“* www.example.com”来查找WHOIS服务器country-code*.whois-servers.net。大多数BSD和Linux变体中的命令行WHOIS客户端将自动查找适当的WHOIS服务器。
请注意,每个注册商都有自己的格式来呈现这些信息,并且大多数注册商都在其WHOIS服务器上实施了控制,以限制来自同一IP地址的频繁请求。
看看PHPWhois

erhoui1w

erhoui1w5#

使用此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;
  }

}
blmhpbnm

blmhpbnm6#

如今,注册数据访问协议RDAP似乎已经取代了旧的WHOIS。它的主要优点是在全球范围内采用独特的格式,并在一系列RFC中详细说明。自2021年以来,它是互联网标准。它通过http(s)运行。有几个 bootstrap 服务器可以查询,包括rdap.orgiana.orgarin.net。他们很可能会将一个http302 redirect分发给实际的提供者。
最后,我们会回复一个JSON格式的记录,其中包含一个 events 数组,例如:

"events": [
    {
      "eventAction": "expiration",
      "eventDate": "2024-05-24T13:04:21.595Z"
    },
    {
      "eventAction": "registration",
      "eventDate": "2023-05-24T13:04:21.595Z"
    },
    {
      "eventAction": "last changed",
      "eventDate": "2023-05-24T13:04:24.454Z"
    },
    {
      "eventAction": "last update of RDAP database",
      "eventDate": "2023-05-25T07:33:59.494Z"
    }
  ],

RFC 9083指定了9种类型的动作,last update of RDAP database不在其中。它出现在expired draft中,没有标准化,因为它是not an action against the object)。
它有很多库,可以通过http下载文件或解析JSON。这种方法比尝试枚举每个提供程序的格式特性要通用得多。

相关问题