设为首页收藏本站

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย Français

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 26|回复: 4

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

[复制链接]

92

主题

193

回帖

688

积分

高级会员

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

就像帖子 https://www.52.ht/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

[ol]
  • const TIMEOUT = 30;
  • const PORT = 43;
  • const ESTR = 'Domain not found';
  •   function whois(string $domain, string $address): array
  •     {
  •         $curl = null;
  •         $output = '';
  •         $info = array();
  •         if (!function_exists('curl_version')) {
  •             trigger_error('cURL is not found!');
  •         } else {
  •             $curl = curl_init();
  •             curl_setopt($curl, CURLOPT_URL, $address);
  •             curl_setopt($curl, CURLOPT_PORT, PORT);
  •             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  •             curl_setopt($curl, CURLOPT_TIMEOUT, TIMEOUT);
  •             curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $domain . "\r\n");
  •             $output = curl_exec($curl);
  •             curl_close($curl);
  •             $info['domain'] = $domain;
  •             (strstr($output, ESTR)) ? $info['status'] = 0 : $info['status'] = 1;
  •             (strstr($output, ESTR)) ? $info['description'] = '掉啦,赶紧抢吧' : $info['description'] = '卧槽,还没掉';
  •             $info['whois'] = $output;
  •         }
  •         return($info);
  •     }
  • print_r(whois('a.dog','whois.nic.dog'));[/ol]复制代码

    SOCKET

    [ol]
  • const TIMEOUT = 30;
  • const PORT = 43;
  • const ESTR = 'Domain not found';
  •   function whois(string $domain, string $address): array
  •     {
  •         $output = '';
  •         $info = array();
  •         $connection = fsockopen($address, PORT, $errno, $errmessage, TIMEOUT);
  •         if (!$connection) {
  •             echo('Connection failed! ' . 'Error no: ' . $errno . ' Error message: ' . $errmessage);
  •             exit();
  •         } else {
  •             ($connection) ? fputs($connection, $domain . "\r\n") : $connection = null;
  •             if (!is_null($connection)) {
  •                 while (!feof($connection)) $output .= fgets($connection);
  •                     $info['domain'] = $domain;
  •             (strstr($output, ESTR)) ? $info['status'] = 0 : $info['status'] = 1;
  •             (strstr($output, ESTR)) ? $info['description'] = '掉啦,赶紧抢吧' : $info['description'] = '卧槽,还没掉';
  •             $info['whois'] = $output;
  •             } else {
  •                 trigger_error('$connection variable is null!');
  •                 exit();
  •             }
  •         }
  •         fclose($connection);
  •         return($info);
  •     }
  • print_r(whois('a.dog','whois.nic.dog'));[/ol]复制代码

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

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





  • 回复

    使用道具 举报

    92

    主题

    193

    回帖

    688

    积分

    高级会员

    积分
    688
     楼主| 发表于 2019-12-1 08:44:19 | 显示全部楼层

    秘密 发表于 2019-12-1 08:44

    真正的好域名都要竞价,哪轮得到自己抢住


    我这里主要是针对非主流冷门后缀,主流的 com net org 没想过要自己抢,就像当年掉的 com.ax tom.cat 这种,都是可以通过自己的技术手段悄悄抢注的
    回复

    使用道具 举报

    46

    主题

    286

    回帖

    780

    积分

    高级会员

    积分
    780
    发表于 2019-12-1 08:48:12 | 显示全部楼层
    最快的接口还是enom,还是乖乖开个根API账号吧
    回复

    使用道具 举报

    92

    主题

    193

    回帖

    688

    积分

    高级会员

    积分
    688
     楼主| 发表于 2019-12-1 08:44:00 | 显示全部楼层

    lyhiving 发表于 2019-12-1 08:49

    最快的接口还是enom,还是乖乖开个根API账号吧

    enom没用过,我知道新后缀速度最快的注册商API是 dynadot
    回复

    使用道具 举报

    124

    主题

    598

    回帖

    1678

    积分

    金牌会员

    积分
    1678
    发表于 2019-12-1 08:49:59 | 显示全部楼层
    一般好的都被namejet  搞定了 这些代码抢不过的
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-12-20 17:42 , Processed in 0.026159 second(s), 5 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2025 Discuz! Team.

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