File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 641
641
## Web Programming
642
642
* [ Crawl Google Results] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/crawl_google_results.py )
643
643
* [ Current Stock Price] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/current_stock_price.py )
644
+ * [ Current Weather] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/current_weather.py )
644
645
* [ Emails From Url] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/emails_from_url.py )
645
646
* [ Fetch Bbc News] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_bbc_news.py )
646
647
* [ Fetch Github Info] ( https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_github_info.py )
Original file line number Diff line number Diff line change 1
- from pprint import pprint
2
-
3
1
import requests
4
2
5
3
APPID = "" # <-- Put your OpenWeatherMap appid here!
6
- URL_BASE = "http://api.openweathermap.org/data/2.5/weather"
4
+ URL_BASE = "http://api.openweathermap.org/data/2.5/"
5
+
6
+
7
+ def current_weather (q : str = "Chicago" , appid : str = APPID ) -> dict :
8
+ """https://openweathermap.org/api"""
9
+ return requests .get (URL_BASE + "weather" , params = locals ()).json ()
7
10
8
11
9
- def current_weather (location : str = "Chicago" , appid : str = APPID ) -> dict :
10
- return requests .get (URL_BASE , params = {"appid" : appid , "q" : location }).json ()
12
+ def weather_forecast (q : str = "Kolkata, India" , appid : str = APPID ) -> dict :
13
+ """https://openweathermap.org/forecast5"""
14
+ return requests .get (URL_BASE + "forecast" , params = locals ()).json ()
15
+
16
+
17
+ def weather_onecall (lat : float = 55.68 , lon : float = 12.57 , appid : str = APPID ) -> dict :
18
+ """https://openweathermap.org/api/one-call-api"""
19
+ return requests .get (URL_BASE + "onecall" , params = locals ()).json ()
11
20
12
21
13
22
if __name__ == "__main__" :
23
+ from pprint import pprint
24
+
14
25
while True :
15
26
location = input ("Enter a location:" ).strip ()
16
27
if location :
You can’t perform that action at this time.
0 commit comments