[Модуль] Погода от Яндекс (app_yaweather)

Разработка дополнительных модулей, подключение различных приложений.

Модератор: immortal

ahelper
Сообщения: 106
Зарегистрирован: Ср фев 08, 2017 5:04 pm
Благодарил (а): 34 раза
Поблагодарили: 66 раз

Re: Модуль "Погода от Яндекс"

Сообщение ahelper » Ср фев 08, 2017 5:37 pm

Приветствую. Только начинаю все изучать. Создал сценарий погоды от Яндекса с кодом
СпойлерПоказать
//Тест разбора погоды от Яндекса
$data_file="https://export.yandex.ru/bar/reginfo.xm ... xml?".rand(); // адрес xml файла

$xml = simplexml_load_file($data_file); // раскладываем xml на массив


sg("PogodaYavObn.City",$xml->weather->day->title);
sg("PogodaYavObn.Country",$xml->weather->day->country);
sg("PogodaYavObn.SunRise",$xml->weather->day->sun_rise);
sg("PogodaYavObn.SunSet",$xml->weather->day->sunset);

sg("PogodaYavObn.Type",$xml->weather->day->day_part->weather_type);
sg("PogodaYavObn.Code",$xml->weather->day->day_part->weather_code);
sg("PogodaYavObn.WindSpeed",$xml->weather->day->day_part->wind_speed);
sg("PogodaYavObn.WindDir",$xml->weather->day->day_part->wind_direction);
sg("PogodaYavObn.Humidity",$xml->weather->day->day_part->dampness);
sg("PogodaYavObn.Hectopascal",$xml->weather->day->day_part->hectopascal);
sg("PogodaYavObn.Torr",$xml->weather->day->day_part->torr);
sg("PogodaYavObn.Pressure",$xml->weather->day->day_part->pressure);
sg("PogodaYavObn.Temp",$xml->weather->day->day_part->temperature);
sg("PogodaYavObn.Observ_time",$xml->weather->day->day_part->observation_time);
//sg("PogodaYavObn.Image",$xml->weather->day->day_part->image-v3);
sg("PogodaYavObn.Image",$xml->weather->day->day_part->image);
Подскажите пожалуйста, как мне извлечь картинку с предпоследней закомментированой строки?
Код XML страницы выглядит так
СпойлерПоказать
<day_part typeid="2" type="день">
<weather_type>переменная облачность</weather_type>
<weather_code>partly-cloudy</weather_code>
<image>
https://yastatic.net/weather/i/icons/bl ... /bkn_d.png
</image>
<image-v2 size="22x22">
http://yandex.st/weather/v-1/i/icons/22 ... _d_-12.png
</image-v2>
<image-v3 size="48">
https://yastatic.net/weather/i/icons/bl ... /bkn_d.png
</image-v3>
За это сообщение автора ahelper поблагодарил:
dimabolt (Вс янв 07, 2018 11:23 pm)
Рейтинг: 1.16%
Аватара пользователя
nick7zmail
Сообщения: 7573
Зарегистрирован: Пн окт 28, 2013 8:14 am
Откуда: Екатеринбург
Благодарил (а): 121 раз
Поблагодарили: 2010 раз

Re: Модуль "Погода от Яндекс"

Сообщение nick7zmail » Чт фев 09, 2017 9:03 am

ahelper писал(а): Подскажите пожалуйста, как мне извлечь картинку с предпоследней закомментированой строки?
Код XML страницы выглядит так
СпойлерПоказать
<day_part typeid="2" type="день">
<weather_type>переменная облачность</weather_type>
<weather_code>partly-cloudy</weather_code>
<image>
https://yastatic.net/weather/i/icons/bl ... /bkn_d.png
</image>
<image-v2 size="22x22">
http://yandex.st/weather/v-1/i/icons/22 ... _d_-12.png
</image-v2>
<image-v3 size="48">
https://yastatic.net/weather/i/icons/bl ... /bkn_d.png
</image-v3>
В значение скорее всего попадает что-то типа (в данном случае) bkn_d....чтобы вывести это на сцену/в какой либо элемент - нужно примерно следующее...вставляем, как обычную картинку, только имя заменяем на свойство...как то так

Код: Выделить всё

<img src="https://yastatic.net/weather/i/icons/blueye/48/%PogodaYavObn.Image%.png"> 
Raspberry Pi3+Broadlink+esp8266 (blynk)+AMS
Если вам помогло какое-либо сообщение - не забывайте пользоваться кнопкой "СПАСИБО".
:arrow: Услуги в профиле коннект
>>>>>Мой новый канал на ютутбе, подписывайтесь!<<<<<
directman66
Сообщения: 2801
Зарегистрирован: Пн дек 26, 2016 9:51 am
Откуда: Екатеринбург
Благодарил (а): 380 раз
Поблагодарили: 693 раза
Контактная информация:

Re: Модуль "Погода от Яндекс"

Сообщение directman66 » Вс фев 19, 2017 7:32 am

кстати, неплохо забирается погода с сайте GISMETEO через web-переменные

примеры настроек:

gismeteo pressure
http://m.gismeteo.com/weather/13056/current/
<p>Pressure:(.+?)mmHg<\/p>


ветер
http://m.gismeteo.ru/weather/13056/current/
<p>Ветер:(.+?)<\/p>

gismeteo Humidity
http://m.gismeteo.com/weather/13056/current/
За это сообщение автора directman66 поблагодарил:
Samir77 (Пт окт 18, 2019 1:03 am)
Рейтинг: 1.16%
Если вам помогло данное сообщение, не поленитесь нажать кнопку "спасибо".
CONNECT | Оборудование | Блог | Дополнения | Email | Telegram
Аватара пользователя
dioxin
Сообщения: 175
Зарегистрирован: Вт фев 14, 2017 4:43 pm
Откуда: Иваново
Благодарил (а): 15 раз
Поблагодарили: 46 раз

Re: Модуль "Погода от Яндекс"

Сообщение dioxin » Вс фев 19, 2017 9:15 am

А самое главное не вытащил, температуру))
Текущую температуру можно и со своего датчика брать, что несомненно точней.
Алиска прописана на Debian 11 | Мой канал на youtube по MajorDomo
directman66
Сообщения: 2801
Зарегистрирован: Пн дек 26, 2016 9:51 am
Откуда: Екатеринбург
Благодарил (а): 380 раз
Поблагодарили: 693 раза
Контактная информация:

Re: Модуль "Погода от Яндекс"

Сообщение directman66 » Вс фев 19, 2017 5:45 pm

Температуру я тоже беру, просто не указана. В примере.
Если вам помогло данное сообщение, не поленитесь нажать кнопку "спасибо".
CONNECT | Оборудование | Блог | Дополнения | Email | Telegram
Denzot
Сообщения: 8
Зарегистрирован: Пн фев 13, 2017 11:47 am
Благодарил (а): 1 раз
Поблагодарили: 0

Re: Модуль "Погода от Яндекс"

Сообщение Denzot » Вт фев 21, 2017 8:24 pm

Доброе время суток!
ребята, подскажите как исправить ошибку:
КОД ОШИБКИ МОДУЛЯ

Код: Выделить всё

Warning: simplexml_load_file(): entNS";f="firstChild";w="http://www.w3.org/2000/svg";e[c]+=" i-ua_svg_"+(!!d[n]& in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ntNS";f="firstChild";w="http://www.w3.org/2000/svg";e[c]+=" i-ua_svg_"+(!!d[n]&& in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): );v=d.createElement("div");v.innerHTML="<svg/>";e[c]+=" i-ua_inlinesvg_"+((v[f]& in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : EntityRef: expecting ';' in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): v=d.createElement("div");v.innerHTML="<svg/>";e[c]+=" i-ua_inlinesvg_"+((v[f]&&v in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): dow).width();params.blockId=w>1200?"R-I-49688-8":"R-I-49688-32";params.onRender& in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ow).width();params.blockId=w>1200?"R-I-49688-8":"R-I-49688-32";params.onRender&& in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Opening and ending tag mismatch: br line 1 and p in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ooting.xml'>поделитесь ею с нами</a>, пожалуйста.</p> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Opening and ending tag mismatch: br line 1 and div in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): " href="/pogoda/astana">Астана</a></li></ul></div></div></div></div></div> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): </script><script nonce="01d411483a741aa7598f8aa8edb73eea">Boolean(window.Atom) & in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : xmlParseEntityRef: no name in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): /script><script nonce="01d411483a741aa7598f8aa8edb73eea">Boolean(window.Atom) && in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Opening and ending tag mismatch: br line 1 and body in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): quot;show","path":"weather_web.header"}]}}"></i></body> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Opening and ending tag mismatch: p line 1 and html in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ow","path":"weather_web.header"}]}}"></i></body></html> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Premature end of data in tag div line 1 in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ow","path":"weather_web.header"}]}}"></i></body></html> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Premature end of data in tag body line 1 in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ow","path":"weather_web.header"}]}}"></i></body></html> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml:1: parser error : Premature end of data in tag html line 1 in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ow","path":"weather_web.header"}]}}"></i></body></html> in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: simplexml_load_file(): ^ in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 246

Warning: Invalid argument supplied for foreach() in C:\_majordomo\htdocs\modules\app_yaweather\app_yaweather.class.php on line 280
 MajorDoMo


подскажите пожалуйста что не так почему не работает модкль?
Аватара пользователя
dioxin
Сообщения: 175
Зарегистрирован: Вт фев 14, 2017 4:43 pm
Откуда: Иваново
Благодарил (а): 15 раз
Поблагодарили: 46 раз

Re: Модуль "Погода от Яндекс"

Сообщение dioxin » Вт фев 21, 2017 8:29 pm

http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml такого файла просто нет на яндексе. Отсюда и ошибки парсинга.

directman66 - как температуру вытащил? Покажи плиз.
Последний раз редактировалось dioxin Вс апр 02, 2017 1:31 am, всего редактировалось 1 раз.
Алиска прописана на Debian 11 | Мой канал на youtube по MajorDomo
Tem
Сообщения: 36
Зарегистрирован: Ср фев 01, 2017 9:03 am
Благодарил (а): 6 раз
Поблагодарили: 3 раза

Re: Модуль "Погода от Яндекс"

Сообщение Tem » Вт фев 21, 2017 8:58 pm

dioxin писал(а):directman66 - как температуру вытащил? Покажи плиз.
Просто текущую ?
<td class="weather__temp"><span>(.+?)<\/span><\/td>
Denzot
Сообщения: 8
Зарегистрирован: Пн фев 13, 2017 11:47 am
Благодарил (а): 1 раз
Поблагодарили: 0

Re: Модуль "Погода от Яндекс"

Сообщение Denzot » Вт фев 21, 2017 9:00 pm

[quote="dioxin"]http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml такого файла просто нет на яндексе. Отсюда ошибки и парсинга.

подскажите как исправить ошибку
DimSun75
Сообщения: 318
Зарегистрирован: Вс янв 01, 2017 8:32 pm
Откуда: Москва
Благодарил (а): 7 раз
Поблагодарили: 44 раза

Re: Модуль "Погода от Яндекс"

Сообщение DimSun75 » Вт фев 21, 2017 9:17 pm

Denzot писал(а):
dioxin писал(а):http://pogoda.yandex.ru/weather-ng/forecasts/35394.xml такого файла просто нет на яндексе. Отсюда ошибки и парсинга.

подскажите как исправить ошибку
Переписать модуль или договориться с яндексом
Ответить