Unstoppable Domains

[Resolved] PHP Whois

Spaceship Spaceship
Watch
Impact
91
PHP whois

hi

please tell me what php code do i have to write for getting the whois information of a particular domain from the registry?

i am looking for only .com and .net registries right now

thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
The following works for getting whois information:-

PHP:
<?php
$sock = fsockopen('whois.internic.net',43);
fputs($sock,'namepros.com'."\r\n");
while(!feof($sock))
{
	$info .= fgets($sock,128);
}

fclose($sock);
echo $info
?>

The result is in $info (and of course in this example the whois server is hard coded as is the domain name).
 
1
•••
My script checks whois.crsnic.net which should refer to each individual registrars whois server, and if it can't connect to crsnic for whatever reason, it connects to internic instead.

Same code though essentially.
 
0
•••
please tell me which one of the two should i use ? which is better?
 
0
•••
i used the code and it worked perfectly

can u please explain some things to me that i fail to grasp:
1. why are we using
Code:
$info .= fgets($sock,128);
doesn't is mean $info=fgets($sock,128) . $info ?
what is the use of Concatenate here?

2. what is 128 in the fget()?

thanks
 
0
•••
1) The concatenate is used to add the string (fgets($sock,128);) to the $info variable (i.e. because then, after the loop's complete, "echo $info" can be used in one go to echo everything). But yes, "$info=fgets($sock,128) . $info" should also do the same thing.

2) The 128 is the maximum length of what's returned by the results :)
 
0
•••
Yes as tristanperry stated the 128 is the amount of bytes to read at a time. The reason we specify it as the PHP manual specifies that it is more resource efficient to do so (http://php.net/fgets)

Regarding the $info .= fgets($sock,128); line it achieves exactly the same as what you wrote but is just another way of doing it.
 
0
•••
thanks guys..

but there seems to be a problem with bulk whois checkups. does any body know how to successfuly conduct checks?

thanks
 
0
•••
champ_rock said:
thanks guys..

but there seems to be a problem with bulk whois checkups. does any body know how to successfuly conduct checks?

thanks
The registries don't like spam-bots/email-harvesters from hitting the registry with too many requests too fast, so they place limits. PIR (the .org registry) is especially known for this. Try adding PHP's sleep() or usleep() functions in conjunction with set_time_limit() to delay each query to avoid this problem.
 
0
•••
lol email harvesting..

i thought that whois queries were generally used for checking doamin availabilities

thanks.. i will use the sleep() function
 
0
•••
Some spammers use whois results to harvest email accounts as stated by maximum.

Another method than using usleep etc is by using more than 1 whois server and alternate between which ones you use.
 
0
•••
i guess the 2 whois servers for querying .com and .net names are crsnic and internic right?
 
0
•••
whois.verisign-grs.net
 
0
•••
thanks to this thread I wrote a simple scanner last night, it alternates between 3 whois servers.
 
0
•••
samuofm said:
thanks to this thread I wrote a simple scanner last night, it alternates between 3 whois servers.
i gues the registry is doing some kind of updates because sometimes i am able to do bulk checks and after some days the scanner starts giving errors
 
0
•••
samuofm said:
thanks to this thread I wrote a simple scanner last night, it alternates between 3 whois servers.

cool glad it inspired you
:)

champ_rock said:
i gues the registry is doing some kind of updates because sometimes i am able to do bulk checks and after some days the scanner starts giving errors


What sort of response are you getting from them when you get an error?
 
0
•••
here is the error
Warning: fsockopen() [function.fsockopen]: unable to connect to whois.crsnic.net:43 in /home/XXXXXX/public_html/XXXXXX/index.php on line 11

Warning: fputs(): supplied argument is not a valid stream resource in /home/XXXXX/public_html/XXXXX/index.php on line 12

Warning: feof(): supplied argument is not a valid stream resource in /home/XXXXX/public_html/XXXX/index.php on line 13

Warning: fgets(): supplied argument is not a valid stream resource in /home/XXXX/public_html/XXXX/index.php on line 15
 
0
•••
That means that the whois servers are denying your connection requests. Or, a part of the network between your server and the whois server is down.
 
0
•••
ya it is denying my requests.

this is happening after i check about 10-12 domains :(

if anyone finds a solution to this then it would be great
 
0
•••
What I'd like to know is how you get around the issue of some registrar's not listing complete info in their whois registries and forcing you to use a web interface with a captcha to get the information.
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back