Показать сообщение отдельно

  #7  
Старый 15.08.2009, 20:25
b3
Постоянный
Регистрация: 05.12.2004
Сообщений: 647
С нами: 11278406

Репутация: 818


По умолчанию

Погода на weather.bigmir.net

PHP код:
<?php
class weather
{
########################################
#
# Погода на weather.bigmir.net
#
########################################
var $url 'http://weather.bigmir.net/main/harkov/8956/';

var 
$celsius 'N\A';
var 
$windspeed 'N\A';
var 
$vlaga 'N\A';
var 
$visibility 'N\A';
var 
$obl 'N\A';
var 
$date 'N\A';
var 
$city 'N\A';

function 
weather()
{
$url file_get_contents($this->url);
#
if(preg_match('#<span id=\'TemperatureCelsius\'>(.*)<\/span>#',$url,$matches))
$this->celsius $matches[1];

if(
preg_match('#<span id=\'WindSpeed\'>(.*)<\/span>#U',$url,$matches))
$this->windspeed $matches[1].'м/с';

if(
preg_match('#<span id=\'RelativeHumidity\'>(.*)<\/span>#U',$url,$matches))
$this->vlaga $matches[1].'%';

if(
preg_match('#<span id=\'VisibilityKM\'>(.*)<\/span>#U',$url,$matches))
$this->visibility $matches[1].'км';

if(
preg_match('#<span id=\'CloudCoverage\'>(.*)</span>#U',$url,$matches))
$this->obl $matches[1].'%';

if(
preg_match('#<span id=\'forecastDate\'>(.*?)</span>#U',$url,$matches))
$this->date 'Погода на '.$matches[1];

if(
preg_match('#<div class="fl mrt_small">Погода в (.*)<\/div>#U',$url,$matches))
$this->city 'В '.$matches[1];
}
}

$a = new weather;
echo 
$a->city.'<br />';
echo 
$a->date.'<br />';
echo 
'Температура '.$a->celsius.'<br />';
echo 
'Скорость ветра '.$a->windspeed.'<br />';
echo 
'Влажность '.$a->vlaga.'<br />';
echo 
'Видимость '.$a->visibility.'<br />';
echo 
'Облачность '.$a->obl.'<br />';
?>
 
Ответить с цитированием