CrazeeIvan / python-weather-api

Automatically exported from code.google.com/p/python-weather-api
MIT License
0 stars 0 forks source link

Can't always retrieve data from Google #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call "get_weather_from_google" multiple times.

Sometimes you can retrieve values and sometimes you end up with "Unsupported 
API". Since it is generally working, Google seems to have servers, that do not 
answer to pywapi any more.

In [11]: cW.weatherCheck()
<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" 
tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" 
><forecast_information><city data="Würselen, North 
Rhine-Westphalia"/><postal_code data="Wuerselen"/><latitude_e6 
data=""/><longitude_e6 data=""/><forecast_date 
data="2012-08-24"/><current_date_time data="1970-01-01 00:00:00 
+0000"/><unit_system 
data="US"/></forecast_information><current_conditions><condition 
data="Clear"/><temp_f data="75"/><temp_c data="24"/><humidity data="Humidity: 
44%"/><icon data="/ig/images/weather/sunny.gif"/><wind_condition data="Wind: S 
at 6 mph"/></current_conditions><forecast_conditions><day_of_week 
data="Fri"/><low data="57"/><high data="79"/><icon 
data="/ig/images/weather/chance_of_rain.gif"/><condition data="Chance of 
Rain"/></forecast_conditions><forecast_conditions><day_of_week data="Sat"/><low 
data="55"/><high data="77"/><icon 
data="/ig/images/weather/chance_of_rain.gif"/><condition data="Chance of 
Rain"/></forecast_conditions><forecast_conditions><day_of_week data="Sun"/><low 
data="50"/><high data="70"/><icon 
data="/ig/images/weather/chance_of_rain.gif"/><condition data="Chance of 
Rain"/></forecast_conditions><forecast_conditions><day_of_week data="Mon"/><low 
data="57"/><high data="75"/><icon 
data="/ig/images/weather/mostly_sunny.gif"/><condition data="Mostly 
Sunny"/></forecast_conditions></weather></xml_api_reply>
(u'24', 44, 'S', 6, u'Clear')

In [12]: cW.weatherCheck()
Unsupported API
---------------------------------------------------------------------------
ExpatError                                Traceback (most recent call last)
/home/pmichalschik/Python/testlib/<ipython-input-12-9bf3a48fa2e2> in <module>()
----> 1 cW.weatherCheck()

/home/pmichalschik/Python/testlib/checkWeatherCondition.pyc in weatherCheck()
     88 
     89         W = weatherCondition.Weather()
---> 90         W.updateWeatherCondition()
     91 
     92         humidityValue, windDir, windSpeed = formatOutput(W.getHumidityinPercent(),W.getWindSpeedInMph())

/home/pmichalschik/Python/testlib/weatherCondition.pyc in 
updateWeatherCondition(self, place)
     12 
     13         def updateWeatherCondition(self,place='Wuerselen'):
---> 14                 weather = pywapi.get_weather_from_google(place)
     15                 self.tempInC = weather['current_conditions']['temp_c']
     16                 self.humidityinPercent = weather['current_conditions']['humidity']

/usr/local/lib/python2.7/dist-packages/pywapi.py in 
get_weather_from_google(location_id, hl)
     64         xml_response = handler.read()
     65         print xml_response
---> 66     dom = minidom.parseString(xml_response)
     67     handler.close()
     68 

/usr/lib/python2.7/xml/dom/minidom.py in parseString(string, parser)
   1928     if parser is None:
   1929         from xml.dom import expatbuilder
-> 1930         return expatbuilder.parseString(string)
   1931     else:
   1932         from xml.dom import pulldom

/usr/lib/python2.7/xml/dom/expatbuilder.py in parseString(string, namespaces)
    938     else:
    939         builder = ExpatBuilder()
--> 940     return builder.parseString(string)
    941 
    942 

/usr/lib/python2.7/xml/dom/expatbuilder.py in parseString(self, string)
    221         parser = self.getParser()
    222         try:
--> 223             parser.Parse(string, True)
    224             self._setup_subset(string)
    225         except ParseEscape:

ExpatError: syntax error: line 1, column 0

Original issue reported on code.google.com by MTro...@gmail.com on 24 Aug 2012 at 2:26

GoogleCodeExporter commented 8 years ago
Probably it has something to do with automated queries 
(http://support.google.com/websearch/bin/answer.py?hl=en&answer=86640&rd=1).

Original comment by xm.kou...@gmail.com on 29 Aug 2012 at 11:12

GoogleCodeExporter commented 8 years ago
I have a script that retrieves weather data every five minutes, so you might be 
right, nevertheless this problem didn't occur in the last five or six months 
and I have switched to Yahoo Weather instead, which is working fine. 

So if no one else is running into that problem with the Google API, then my IP 
might have gotten onto a blacklist that prohibits such frequent queries. 

Original comment by MTro...@gmail.com on 3 Sep 2012 at 8:06

GoogleCodeExporter commented 8 years ago
Google stopped his weather api ... no longer works.

Original comment by cyril.pf...@orsay.com on 24 Sep 2012 at 10:04

GoogleCodeExporter commented 8 years ago
Thanks for the notice. I hope that Yahoo won't follow any time soon. :-)

Original comment by MTro...@gmail.com on 24 Sep 2012 at 10:33

GoogleCodeExporter commented 8 years ago
Google has discontinued their Weather API as of August 2012, this cannot be 
fixed.

Original comment by jtas...@gmail.com on 9 Mar 2013 at 2:15