GithubHelp home page GithubHelp logo

brextonpham / python-ultron Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 1.17 MB

License: MIT License

Python 89.19% Makefile 0.43% Java 0.30% Batchfile 0.22% CSS 1.83% JavaScript 0.83% HTML 5.46% TeX 0.87% ApacheConf 0.05% Shell 0.51% C 0.31%

python-ultron's Introduction

Copy of http://code.google.com/p/python-weather-api/ page.


=Introduction=

The module provides a python wrapper around the Yahoo! Weather, Weather.com and NOAA APIs.

Authors: Eugene Kaznacheev <[email protected]>
         Joshua Tasker <[email protected]>
         
(*pywapi* - Python Weather API)

=Building=

==From source ==

Download the latest pywapi library from: https://launchpad.net/python-weather-api/trunk/0.3.8/+download/pywapi-0.3.8.tar.gz


Untar the source distribution and run: 
{{{
  $ python setup.py build
  $ python setup.py install
}}}

=Getting the code=

View the trunk at: 
http://python-weather-api.googlecode.com/svn/trunk/

Check out the latest development version anonymously with: 
{{{
svn checkout http://python-weather-api.googlecode.com/svn/trunk/ python-weather-api-read-only
}}}

=Documentation=

== Yahoo! Weather ==
Use the following function, that fetches weather report from Yahoo

=== *pywapi.get_weather_from_yahoo(* _location_id_ *,* _ units = 'metric' _ *)* ===


*location_id*: A five digit US zip code or location ID. To find your location ID,
browse or search for your city from the Weather home page (http://weather.yahoo.com/)
The weather ID is in the URL for the forecast page for that city. You can also get the location ID by entering your zip code on the home page. For example, if you search for Los Angeles on the Weather home page, the forecast page for that city is http://weather.yahoo.com/forecast/USCA0638.html. The location ID is USCA0638.

*units*: type of units. 'metric' for metric and '' for non-metric
Note that choosing metric units changes all the weather units to metric, for example, wind speed will be reported as kilometers per hour and barometric pressure as millibars.
Default value is 'metric'.

Returns:
*weather_data*: a dictionary of weather data that exists in XML feed. See http://developer.yahoo.com/weather/#channel

 * [ExampleOfYahooXML Example of XML response from Yahoo]
 * [Examples#Yahoo!_Weather Example of return data]



== Weather.com ==

Use the following function, that fetches weather report from Weather.com

=== *pywapi.get_weather_from_weather_com(* _location_id_ *,* _ units = 'metric' _ *)* ===

*location_id*: A five digit US zip code or location ID. To find your location ID,
browse or search for your city from the Weather.com home page (http://www.weather.com/)
The weather ID is in the URL for the forecast page for that city. You can also get the location ID by entering your zip code on the home page. For example, if you search for Los Angeles on the Weather home page, the forecast page for that city is http://www.weather.com/weather/today/Los+Angeles+CA+USCA0638:1:US. The location ID is USCA0638.

*units*: type of units. 'metric' for metric and '' for non-metric
Note that choosing metric units changes all the weather units to metric, for example, wind speed will be reported as kilometers per hour and barometric pressure as millibars. Default value is 'metric'.

Returns:
*weather_data*: a dictionary of weather data that exists in XML feed.

 * [ExampleOfWeatherComXML Example of XML response from Weather.com]
 * [Examples#Weather.com Example of return data]


== NOAA ==
Use the following function, that fetches weather report from NOAA: National Oceanic and Atmospheric Administration (United States)

=== *pywapi.get_weather_from_noaa(* _station_id_ *)* ===

*station_id*: the ID of the weather station near the necessary location

To find your station ID, perform the following steps:
 # Open this URL: http://www.weather.gov/xml/current_obs/seek.php?state=az&Find=Find
 # Select the necessary state state. Click 'Find'.
 # Find the necessary station in the 'Observation Location' column.
 # The station ID is in the URL for the weather page for that station.

For example if the weather page is http://weather.noaa.gov/weather/current/KPEO.html -- the station ID is KPEO.

Other way to get the station ID: use this library: http://code.google.com/p/python-weather/ and _Weather.location2station_ function.

Returns:
*weather_data*: a dictionary of weather data that exists in XML feed.

 * [ExampleOfNoaaXML Example of XML response from NOAA]
 * [Examples#NOAA Example of return data]

(useful icons: http://www.weather.gov/xml/current_obs/weather.php)



=Examples=

===[Examples More examples]===

==Script==
{{{
import  pywapi
import string

weather_com_result = pywapi.get_weather_from_weather_com('10001')
yahoo_result = pywapi.get_weather_from_yahoo('10001')
noaa_result = pywapi.get_weather_from_noaa('KJFK')

print "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "C now in New York.\n\n"

print "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + "C now in New York.\n\n"

print "NOAA says: It is " + string.lower(noaa_result['weather']) + " and " + noaa_result['temp_c'] + "C now in New York.\n"
}}}

==Result==
{{{
[~] python examples/pywapi-example.py

Weather.com says: It is overcast and 15C now in New York.

Yahoo says: It is fog and 14C now in New York.

NOAA says: It is overcast and 15C now in New York.

}}}

= Where is it used? =
Weather script for `GeekTool`: http://www.leancrew.com/all-this/2009/06/new-weather-script-for-geektool/

Google Wave robot: http://code.google.com/p/firstwave/wiki/DrWeather

http://blog.chrisramsay.co.uk/2009/08/11/getting-weather-information-with-python/

Weather plugins for Dreambox E2: http://linux-sat.tv/index.php/topic,314.msg1328/topicseen.html#msg1328.

python-ultron's People

Watchers

James Cloos avatar Brexton Pham avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.