Re: Как погоду настроить
Добавлено: Пт май 20, 2016 9:14 am
Gismeteo?
Посмотрите тут http://majordomo.smartliving.ru/forum/v ... &start=120 В конце есть на текущий момент рабочий скрипт забора погоды с яндекса.Bagir писал(а):Добрался и я до погоды. Думал что то сломалось. И верно, сначала через раз, а последнее время вообще не даёт погоду. Жаль, очень удобно было. Зажмотили нам похоже сервис Яндекса.
вот:71Gavrik71 писал(а):Уважаемые гуру, не могли бы помочь достать время захода с гисметио)))
ссылка https://www.gismeteo.ru/city/daily/4392/
код:
<div class="astronomy_item">
<span class="astronomy_title">Заход</span>
<b class="astronomy_value">20:41</b>
</div>
Все что удалось достать мне это: <b class="astronomy_value">20:41, вот таким шаблоном: Заход<\/span>(.+?)<\/b>
Огромное спасибо!!!ILGAS писал(а):вот:71Gavrik71 писал(а):Уважаемые гуру, не могли бы помочь достать время захода с гисметио)))
ссылка https://www.gismeteo.ru/city/daily/4392/
код:
<div class="astronomy_item">
<span class="astronomy_title">Заход</span>
<b class="astronomy_value">20:41</b>
</div>
Все что удалось достать мне это: <b class="astronomy_value">20:41, вот таким шаблоном: Заход<\/span>(.+?)<\/b>
Заход.+?value">(.+?)<\/b>
Код: Выделить всё
$url = "";
$xml = simplexml_load_file($url);
$city = "NTuraGismeteo";
$name = $xml->location['name']; if(gg($city.".name")!=$name){sg($city.".name",$name);}
$name_r = $xml->location['name_r']; if(gg($city.".name_r")!=$name_r){sg($city.".name_r",$name_r);}
$durm = $xml->location->day[0]['durm']; if(gg($city.".durm")!=$durm){sg($city.".durm",$durm);}
$tmin = $xml->location->day[0]['tmin']; if(gg($city.".tmin")!=$tmin){sg($city.".tmin",$tmin);}
$tmax = $xml->location->day[0]['tmax']; if(gg($city.".tmax")!=$tmax){sg($city.".tmax",$tmax);}
if($tmin>0){$tmin="+".$tmin;} if($tmax>0){$tmax="+".$tmax;}
$pmin = $xml->location->day[0]['pmin']; if(gg($city.".pmin")!=$pmin){sg($city.".pmin",$pmin);}
$pmax = $xml->location->day[0]['pmax']; if(gg($city.".pmax")!=$pmax){sg($city.".pmax",$pmax);}
$wsmin = $xml->location->day[0]['wsmin']; if(gg($city.".wsmin")!=$wsmin){sg($city.".wsmin",$wsmin);}
$wsmax = $xml->location->day[0]['wsmax']; if(gg($city.".wsmax")!=$wsmax){sg($city.".wsmax",$wsmax);}
$hummin = $xml->location->day[0]['hummin']; if(gg($city.".hummin")!=$hummin){sg($city.".hummin",$hummin);}
$hummax = $xml->location->day[0]['hummax']; if(gg($city.".hummax")!=$hummax){sg($city.".hummax",$hummax);}
$cl = $xml->location->day[0]['cl']; if(gg($city.".cl")!=$cl){sg($city.".cl",$cl);}
$pt = $xml->location->day[0]['pt']; if(gg($city.".pt")!=$pt){sg($city.".pt",$pt);}
$pr = $xml->location->day[0]['pr']; if(gg($city.".pr")!=$pr){sg($city.".pr",$pr);}
$ts = $xml->location->day[0]['ts']; if(gg($city.".ts")!=$ts){sg($city.".ts",$ts);}
$descr = $xml->location->day[0]['descr']; if(gg($city.".descr")!=$descr){sg($city.".descr",$descr);}
$grademax = $xml->location->day[0]['grademax']; if(gg($city.".grademax")!=$grademax){sg($city.".grademax",$grademax);}
$today = "Сегодня ".$name_r." ".$tmin."° — ".$tmax."°. ".$descr.". ";
//Сегодня утром
if ($xml->location->day[0]->forecast['tod'] == 1){
$t = $xml->location->day[0]->forecast->values['t'];
if($t>0){$t="+".$t;}
$descr = $xml->location->day[0]->forecast->values['descr'];
$today_morning = "Утром до ".$t."°. ".$descr.". ";
}
//Сегодня днем
if ($xml->location->day[0]->forecast['tod'] == 2){
$t = $xml->location->day[0]->forecast->values['t'];
if($t>0){$t="+".$t;}
$descr = $xml->location->day[0]->forecast->values['descr'];
$today_day = "Днём до ".$t."°. ".$descr.". ";
}
//Сегодня вечером
if ($xml->location->day[0]->forecast['tod'] == 3){
$t = $xml->location->day[0]->forecast->values['t'];
if($t>0){$t="+".$t;}
$descr = $xml->location->day[0]->forecast->values['descr'];
$today_evening = "Вечером до ".$t."°. ".$descr.". ";
}
//Сегодня ночью
if ($xml->location->day[1]->forecast['tod'] == 0){
$t = $xml->location->day[1]->forecast->values['t'];
if($t>0){$t="+".$t;}
$descr = $xml->location->day[1]->forecast->values['descr'];
$today_night = "Ночью до ".$t."°. ".$descr.".";
}
$forecast = $today.$today_morning.$today_day.$today_evening.$today_night;
if(gg($city.".forecast")!=$forecast){sg($city.".forecast",$forecast);}
//Завтра
$tmin = $xml->location->day[1]['tmin'];
$tmax = $xml->location->day[1]['tmax'];
$descr = $xml->location->day[1]['descr'];
if($tmin>0){$tmin="+".$tmin;}
if($tmax>0){$tmax="+".$tmax;}
$tomorrow = "Завтра "." ".$tmin."° — ".$tmax."°. ".$descr.". ";
//Завтра ночью
if ($xml->location->day[2]->forecast['tod'] == 0){
$t = $xml->location->day[2]->forecast->values['t'];
if($t>0){$t="+".$t;}
$descr = $xml->location->day[2]->forecast->values['descr'];
$tomorrow_night = "Завтра ночью до ".$t."°. ".$descr.".";
}
$forecastTomorrow = $tomorrow.$tomorrow_night;
if(gg($city.".forecastTomorrow")!=$forecastTomorrow){sg($city.".forecastTomorrow",$forecastTomorrow);}