-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwttr.py
More file actions
38 lines (26 loc) · 706 Bytes
/
wttr.py
File metadata and controls
38 lines (26 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()