I am trying to find a code that will only display two fields of a whois query
i want a code that will make the output something similar to the below
Registra: ABC registra
Nameservers: ns1.example.com,ns2.example.com
Expiration date: 12-30-2003
Can anyone help me out?
only display certain fields of a whois result
Moderator: General Moderators
-
volumeserver
- Forum Newbie
- Posts: 4
- Joined: Wed May 07, 2003 10:42 pm
-
volumeserver
- Forum Newbie
- Posts: 4
- Joined: Wed May 07, 2003 10:42 pm
internic offers a web-interface to its database. Please note
To get the whois entry for http://www.php.net you can use the link
http://reports.internic.net/cgi-bin/who ... ype=domainbut you want the data for processing not only to display itnow you have to separate the useful data. I chose <pre>...>>> to limit the searchand then a regular expression to extract the fields
There are probably better ways to perform this and no error checking is included.
Please do not abuse the web-interface by querrying each host that requests a document from your server.
so cannot get the whois entry for e.g. http://www.heise.de from internic.For Whois information about country-code (two-letter) top-level domains, try Uwhois.com
To get the whois entry for http://www.php.net you can use the link
http://reports.internic.net/cgi-bin/who ... ype=domain
Code: Select all
<?php
$domain = 'php.net';
$url = 'http://reports.internic.net/cgi-bin/whois?whois_nic='.$domain.'&type=domain';
readfile($url);
?>Code: Select all
<?php
$domain = 'php.net';
$url = 'http://reports.internic.net/cgi-bin/whois?whois_nic='.$domain.'&type=domain';
$result = file_get_contents($url); // php4.3+ function
?>Code: Select all
<?php
$posStart = strpos($result, '<pre>');
$posEnd = strpos($result, '>>>', $posStart);
$result = substr($result, $posStart, $posEnd-$posStart);
?>Code: Select all
<?php
$info = preg_match_all("!^\s+([^:]*):\s(.*)\n!mi", $result, $matches);
echo '<pre>';
print_r($matches);
echo '</pre>';
?>Please do not abuse the web-interface by querrying each host that requests a document from your server.
-
volumeserver
- Forum Newbie
- Posts: 4
- Joined: Wed May 07, 2003 10:42 pm