Skip to content

Simple cmdline wttr consumer to view city weather #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Basic Scripts/wttr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
::@name Get Weather for a city and display it in the console

::@description
Takes input for city. Gives output of weather for a city in a text format.
Command arg -c City
::@/description

"""
import argparse
import requests


PARSER = argparse.ArgumentParser()

PARSER.add_argument(
"-c",
"--city",
dest="city",
default="Christchurch",
help="Name of the City to display weather info from wttr.in",
)


ARGS = PARSER.parse_args()

CITY = ARGS.city


def get_weather():
"""Display Weather for city in console"""
url = f"https://wttr.in/{CITY}"
response = requests.get(url=url, timeout=None)
print(response.text)


if __name__ == "__main__":
get_weather()