dongqiao3927 2010-05-06 14:46
浏览 22
已采纳

php工具 - 从区域文件中提取域名?

i have access to the zone file for a tld. How can I extract just the domain names in the fastest possible way?

Any suggestions on how to store them in a database/file? There are millions of them.

  • 写回答

1条回答 默认 最新

  • dongyanju0945 2010-05-06 15:27
    关注

    Note, i'm just rattling off code here. This would be the general idea, but the code may need editing. In fact, it almost certainly does.

    $fin = fopen('your zone file', 'r');
    while (!feof($fin))
    {
        $matches = array();
        $line = trim(fgets($fin));
        // only care about lines that are ip addresses or aliases
        if (preg_match('/^(\S+)\s+((?:IN\s+)?)(A|AAAA|CNAME)\s+(\S+)$/i', $line, $matches))
        {
            $subdomain = $matches[1];
            $ip_or_alias = $matches[4];
            do_something($subdomain, $ip_or_alias);
        }
    }
    fclose($fin);
    

    You'd define a function do_something that would take the info and store it somewhere. Or, put the code right there where the function call is instead.

    As for how to store it, that depends a lot on what you're going to do with it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度