全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1761|回复: 5

通过PHP代码进行域名抢注的技术资料分享

[复制链接]
发表于 2019-12-1 08:39:36 | 显示全部楼层 |阅读模式
数天前,我曾经发帖详细介绍了通过域名抢注发财的业务流程,朋友们反应热烈,有人加我问哪里有相关抢注代码

就像帖子 https://www.hostloc.com/thread-613066-1-1.html 说的,域名抢注需要代码的主要是两个地方 1.查询 whois 2.提交api

第二点 提交api的代码,这个主要得根据服务商提供的api文档进行编程

hexonet 的API文档地址 https://github.com/hexonet/hexonet-api-documentation/blob/master/API/DOMAIN/ADDDOMAIN.md

也有程序员为 hexonet 的api接口提供了一个PHP源码 https://github.com/al-one/hexonet-api

dynadot.com 的抢注API地址 https://www.dynadot.com/domain/api2.html ,它比较简单,只要一个get 或者  post 到一个地址 https://api.dynadot.com/api2.html?key=8S7I2s6Qd8g&command=register&domain=mydomain.com&duration=1

quyu.net 也有API接口,这个要向趣域客服申请,API PHP 示例代码 https://www.quyu.net/knowledgebase.php?action=displayarticle&id=23

关于第一点,通过PHP代码查询whois的方式主要有两个 1.CURL 2.SOCKET 下面就是相关代码

CURL

  1. const TIMEOUT = 30;
  2. const PORT = 43;
  3. const ESTR = 'Domain not found';
  4.   function whois(string $domain, string $address): array
  5.     {
  6.         $curl = null;
  7.         $output = '';
  8.         $info = array();

  9.         if (!function_exists('curl_version')) {
  10.             trigger_error('cURL is not found!');
  11.         } else {
  12.             $curl = curl_init();
  13.             curl_setopt($curl, CURLOPT_URL, $address);
  14.             curl_setopt($curl, CURLOPT_PORT, PORT);
  15.             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  16.             curl_setopt($curl, CURLOPT_TIMEOUT, TIMEOUT);
  17.             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain . "\r\n");
  18.             $output = curl_exec($curl);
  19.             curl_close($curl);

  20.             $info['domain'] = $domain;
  21.             (strstr($output, ESTR)) ? $info['status'] = 0 : $info['status'] = 1;
  22.             (strstr($output, ESTR)) ? $info['description'] = '掉啦,赶紧抢吧' : $info['description'] = '卧槽,还没掉';
  23.             $info['whois'] = $output;
  24.         }

  25.         return($info);
  26.     }
  27. print_r(whois('a.dog','whois.nic.dog'));
复制代码


SOCKET

  1. const TIMEOUT = 30;
  2. const PORT = 43;
  3. const ESTR = 'Domain not found';
  4.   function whois(string $domain, string $address): array
  5.     {
  6.         $output = '';
  7.         $info = array();
  8.         $connection = fsockopen($address, PORT, $errno, $errmessage, TIMEOUT);

  9.         if (!$connection) {
  10.             echo('Connection failed! ' . 'Error no: ' . $errno . ' Error message: ' . $errmessage);
  11.             exit();
  12.         } else {
  13.             ($connection) ? fputs($connection, $domain . "\r\n") : $connection = null;

  14.             if (!is_null($connection)) {
  15.                 while (!feof($connection)) $output .= fgets($connection);

  16.                     $info['domain'] = $domain;
  17.             (strstr($output, ESTR)) ? $info['status'] = 0 : $info['status'] = 1;
  18.             (strstr($output, ESTR)) ? $info['description'] = '掉啦,赶紧抢吧' : $info['description'] = '卧槽,还没掉';
  19.             $info['whois'] = $output;

  20.             } else {
  21.                 trigger_error('$connection variable is null!');
  22.                 exit();
  23.             }
  24.         }
  25.         fclose($connection);

  26.         return($info);
  27.     }
  28. print_r(whois('a.dog','whois.nic.dog'));
复制代码


然后你找到一个定时任务的脚本,以一定的间隔执行PHP代码查询whois服务器,当发现某个域名掉了,立刻执行域名注册API即可

最后祝大家马到成功,财源滚滚

秘密 该用户已被删除
发表于 2019-12-1 08:44:19 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2019-12-1 08:48:12 | 显示全部楼层
秘密 发表于 2019-12-1 08:44
真正的好域名都要竞价,哪轮得到自己抢住


我这里主要是针对非主流冷门后缀,主流的 com net org 没想过要自己抢,就像当年掉的 com.ax tom.cat 这种,都是可以通过自己的技术手段悄悄抢注的
发表于 2019-12-1 08:49:59 | 显示全部楼层
最快的接口还是enom,还是乖乖开个根API账号吧
 楼主| 发表于 2019-12-1 08:51:03 | 显示全部楼层
lyhiving 发表于 2019-12-1 08:49
最快的接口还是enom,还是乖乖开个根API账号吧

enom没用过,我知道新后缀速度最快的注册商API是 dynadot
发表于 2019-12-1 08:54:14 来自手机 | 显示全部楼层
一般好的都被namejet  搞定了 这些代码抢不过的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-25 22:19 , Processed in 0.068989 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表