Skip to content

Instantly share code, notes, and snippets.

@corvax19
Last active December 9, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corvax19/4346134 to your computer and use it in GitHub Desktop.
Save corvax19/4346134 to your computer and use it in GitHub Desktop.
gist_weather
from urllib import urlopen;
import json, sys;
url = "http://openweathermap.org/data/2.1/find/name?q=" + city;
t = json.load(urlopen(url))['list'][0]['main']['temp'] - 273.15;
print t;
@corvax19
Copy link
Author

Usage:
python <<< echo 'city = "Iecava";'; curl -Ls https://gist.github.com/raw/4346134/760250ba024bfc76a2e5a8ec0725c9b05cde9a48/gistfile1.py

@corvax19
Copy link
Author

bash script with city as a command line argument:

!/bin/env bash

python <<< echo "city = \"$1\";"; curl -Ls https://gist.github.com/raw/4346134/760250ba024bfc76a2e5a8ec0725c9b05cde9a48/gistfile1.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment