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.
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.
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.