helper-scripts/getweather.py

18 lines
357 B
Python
Raw Permalink Normal View History

2019-01-20 14:16:52 -08:00
#!/usr/bin/python3
"""Obtain a weather forecast."""
import argparse
import requests
# ========== Constants ==========
2019-01-20 14:16:52 -08:00
WTTR_URI = 'http://wttr.in'
# ========== Main Script ==========
parser = argparse.ArgumentParser()
parser.add_argument('location')
2019-01-20 14:16:52 -08:00
args = parser.parse_args()
location = args.location
2019-01-20 14:16:52 -08:00
print(requests.get(f"{WTTR_URI}/{location}").text)