Skip to content

Commit

Permalink
handle cities with spaces in the urllib.request version of weather05.…
Browse files Browse the repository at this point in the history
…py (#3871)

handle cities with spaces in the urllib.request version of weather
  • Loading branch information
danschwarz authored Dec 14, 2023
1 parent 49e7186 commit 2dd6e92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/examples/guide/workers/weather05.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from urllib.parse import quote
from urllib.request import Request, urlopen

from rich.text import Text
Expand Down Expand Up @@ -30,7 +31,7 @@ def update_weather(self, city: str) -> None:
worker = get_current_worker()
if city:
# Query the network API
url = f"https://wttr.in/{city}"
url = f"https://wttr.in/{quote(city)}"
request = Request(url)
request.add_header("User-agent", "CURL")
response_text = urlopen(request).read().decode("utf-8")
Expand Down

0 comments on commit 2dd6e92

Please sign in to comment.