Форум сайта python.su
Парсер почему-то некоторые парметры не обрабатывает.
temp_c = b.find('temp_c').text
s_id = b.find('stations_id').text
AttributeError: 'NoneType' object has no attribute 'text'
<response> <version>0.1</version> <termsofService> http://www.wunderground.com/weather/api/d/terms.html </termsofService> <features> <feature>conditions</feature> </features> <current_observation> <image> <url>http://icons.wxug.com/graphics/wu2/logo_130x80.png</url> <title>Weather Underground</title> <link>http://www.wunderground.com</link> </image> <display_location> <full>Saint Petersburg, Russia</full> <city>Saint Petersburg</city> <state/> <state_name>Russia</state_name> <country>RS</country> <country_iso3166>RU</country_iso3166> <zip>00000</zip> <magic>110</magic> <wmo>26063</wmo> <latitude>59.928844</latitude> <longitude>30.310856</longitude> <elevation>3.0</elevation> </display_location> <observation_location> <full>Kazanskaya ulitsa, Sankt-Peterburg,</full> <city>Kazanskaya ulitsa, Sankt-Peterburg</city> <state/> <country>RU</country> <country_iso3166>RU</country_iso3166> <latitude>59.928844</latitude> <longitude>30.310856</longitude> <elevation>52 ft</elevation> </observation_location> <estimated></estimated> <station_id>ISANKTPE186</station_id> <observation_time>Last Updated on November 28, 5:50 AM MSK</observation_time> <observation_time_rfc822>Tue, 28 Nov 2017 05:50:44 +0300</observation_time_rfc822> <observation_epoch>1511837444</observation_epoch> <local_time_rfc822>Tue, 28 Nov 2017 05:56:55 +0300</local_time_rfc822> <local_epoch>1511837815</local_epoch> <local_tz_short>MSK</local_tz_short> <local_tz_long>Europe/Moscow</local_tz_long> <local_tz_offset>+0300</local_tz_offset> <weather>Overcast</weather> <temperature_string>32.4 F (0.2 C)</temperature_string> <temp_f>32.4</temp_f> <temp_c>0.2</temp_c> <relative_humidity>85%</relative_humidity> <wind_string>Calm</wind_string> <wind_dir>North</wind_dir> <wind_degrees>-9999</wind_degrees> <wind_mph>-9999.0</wind_mph> <wind_gust_mph>0</wind_gust_mph> <wind_kph>-999.0</wind_kph> <wind_gust_kph>0</wind_gust_kph> <pressure_mb>1015</pressure_mb> <pressure_in>29.98</pressure_in> <pressure_trend>0</pressure_trend> <dewpoint_string>28 F (-2 C)</dewpoint_string> <dewpoint_f>28</dewpoint_f> <dewpoint_c>-2</dewpoint_c> <heat_index_string>NA</heat_index_string> <heat_index_f>NA</heat_index_f> <heat_index_c>NA</heat_index_c> <windchill_string>32 F (0 C)</windchill_string> <windchill_f>32</windchill_f> <windchill_c>0</windchill_c> <feelslike_string>32 F (0 C)</feelslike_string> <feelslike_f>32</feelslike_f> <feelslike_c>0</feelslike_c> <visibility_mi>6.2</visibility_mi> <visibility_km>10.0</visibility_km> <solarradiation/> <UV>0</UV> <precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string> <precip_1hr_in>0.00</precip_1hr_in> <precip_1hr_metric>0</precip_1hr_metric> <precip_today_string>0.00 in (0 mm)</precip_today_string> <precip_today_in>0.00</precip_today_in> <precip_today_metric>0</precip_today_metric> <icon>cloudy</icon> <icon_url>http://icons.wxug.com/i/c/k/nt_cloudy.gif</icon_url> <forecast_url> http://www.wunderground.com/global/stations/26063.html </forecast_url> <history_url> http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ISANKTPE186 </history_url> <ob_url> http://www.wunderground.com/cgi-bin/findweather/getForecast?query=59.928844,30.310856 </ob_url> </current_observation> </response>
Отредактировано Tenebras (Ноя. 28, 2017 05:57:32)
Офлайн
Офлайн
Чёрт! Спасибо! Сдавать сегодня работу. Ночь не спал… Внимание на нуле!
Теперь можно спокойно идти! Всё остальное работает!
Офлайн