A Python wrapper for the Yahoo Weather API.
With the API, you can get up-to-date weather information for any location, including 5-day forecast, wind, atmosphere, astronomy conditions, and more. You can lookup weather by woeid, city name or lat/long.
For more detailed examples and tutorial, check out Yahoo Weather Developer Page. For more information, check out the API documentation.
pip install weather-api
Lookup WOEID via http://weather.yahoo.com.
from weather import Weather, Unit
weather = Weather(unit=Unit.CELSIUS)
lookup = weather.lookup(560743)
condition = lookup.condition
print(condition.text)
Lookup via location name.
weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('dublin')
condition = location.condition
print(condition.text)
Get weather forecasts for the upcoming days.
weather = Weather(unit=Unit.CELSIUS)
forecasts = location.forecast
for forecast in forecasts:
print(forecast.text)
print(forecast.date)
print(forecast.high)
print(forecast.low)
Lookup via latitude and longitude
weather = Weather(Unit.CELSIUS)
lookup = w.lookup_by_latlng(53.3494,-6.2601)
condition = lookup.condition
print(condition.text)
usage: weather [-h] [--unit [{c,f}]] location
positional arguments:
location The location to lookup.
optional arguments:
-h, --help show this help message and exit
--unit [{c,f}]
$ weather dublin --u c