Witam !
Próbuje napisać skrypt do odczytywania danych whois z serwera whois.dns.pl. Chciałbym także pobierać więcej niż jedną stronę podczas połączenia - czy to jest w ogóle możliwe ?
W tym momencie korzystam z takiego rozwiązania:
function checkDomain($domain,$server,$findText)
{
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con))
$response .= fgets($con,128);
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
return (bool)(strpos($response, $findText));
}
$x[0] = 'const.pl';
$x[1] = 'google.pl';
$x[2] = 'brrrrrsdfr.pl';
for($i=0; $i<=2; $i++)
{
echo $x[0];
echo checkDomain($x[i], 'whois.dns.pl', 'No information about domain') ? '-tak' : '-nie';
echo '<br>';
}
Niestety każdorazowe otwieranie i zamykanie połączenia zajmuje dużo czasu i często dostaję komunikat "Maximum execution time exceeded"
Natomiast takie rozwiązanie działa jedynie dla pierwszej domeny:
<?php
function checkDomain($domain,$server,$findText)
{
global $con;
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con))
$response .= fgets($con,128);
// Check the response stream whether the domain is available
return (bool)(strpos($response, $findText));
}
$x[0] = 'const.pl';
$x[1] = 'google.pl';
$x[2] = 'brrrrrsdfr.pl';
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
for($i=0; $i<=2; $i++)
{
echo $x[0];
echo checkDomain($x[i], 'whois.dns.pl', 'No information about domain') ? '-tak' : '-nie';
echo '<br>';
}
// Close the connection
fclose($con);
Czy można to zrobić tak, żeby w jednym połączeniu pobrać dane na temat kilku stron ?