quote wttr.in requests
This commit is contained in:
parent
e64af1a0a1
commit
2f4156ce26
@ -33,7 +33,7 @@ class Weather(Plugin):
|
||||
if len(queryitems) <= 0:
|
||||
return
|
||||
|
||||
weather = weather_summary(queryitems[0])
|
||||
weather = weather_summary(query)
|
||||
weather_output = (f"Weather in {weather['location']}: {weather['current']['description']}. "
|
||||
f"{weather['current']['temp_F']}/{weather['current']['temp_C']}, "
|
||||
f"feels like {weather['current']['feels_like_temp_F']}/"
|
||||
|
@ -2,6 +2,7 @@
|
||||
"""Get results of weather queries."""
|
||||
import logging
|
||||
import requests
|
||||
from urllib.parse import quote
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -9,7 +10,7 @@ logger = logging.getLogger(__name__)
|
||||
def query_wttr_in(query):
|
||||
"""Hit the wttr.in JSON API with the provided query."""
|
||||
logger.info(f"about to query wttr.in with '{query}'")
|
||||
response = requests.get(f'http://wttr.in/{query}?format=j1')
|
||||
response = requests.get(f'http://wttr.in/{quote(query)}?format=j1')
|
||||
response.raise_for_status()
|
||||
|
||||
weather_info = response.json()
|
||||
|
Loading…
Reference in New Issue
Block a user