class HoroMail {
var $u = '/prediction/{u}/today';
var $x = '/prediction/{u}/tomorrow';
var $c = '';
var $m = '';
function oo($u)
{
if ( ( $io = fsockopen( "horo.mail.ru", 80, $errno, $errstr, 5 ) ) !== false )
{
$send = "GET ".$u." HTTP/1.1\r\n";
$send .= "Host: horo.mail.ru\r\n";
$send .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204\r\n";
$send .= "Connection: Close\r\n\r\n";
fputs( $io, $send );
$send = '';
while ( ! feof ( $io ) )
$send .= fread( $io, 8192 );
fclose( $io );
}
return $send;
}
function o($u)
{
$this->c = $this->oo( str_replace('{u}', $u, $this->u ) );
$this->m = $this->oo( str_replace('{u}', $u, $this->x ) );
$this->p();
}
function p()
{
preg_match('/<div id="tm_today">(.*)<div class="mb2">/ism', $this->c, $this->c);
$this->c = trim(strip_tags($this->c[0],'<p>'));
preg_match('/<div id="tm_tomorrow">(.*)<div class="mb2">/ism', $this->m, $this->m);
$this->m = trim(strip_tags($this->m[0],'<p>'));
}
}
$h = new HoroMail;
$horo = array(
'aries',
'taurus',
'gemini',
'cancer',
'leo',
'virgo',
'libra',
'scorpio',
'sagittarius',
'capricorn',
'aquarius',
'pisces'
);
for ($i=0;$i<12;$i++)
{
$h->o($horo[$i]);
echo '<br /><br />'.$horo[$i].'<br />'.$h->c.'<br /> '.$h->m ;
}
?>
$h = new HoroMail; — подключение класса$h->o($horo[$i]); — сбор гороскопа
$h->c — гороскоп на сегодня
$h->m — гороскоп на завтра
Скрипт обновлен, в связи с обновлениям http://horo.mail.ru/.