wttr.in
wttr.in copied to clipboard
%l output is unexpected in some cases
this output is expected:
> curl wttr.in?format=%l
Dallas, Texas, United States
however if you specify location, you get different format:
> curl wttr.in/Dallas?format=%l
Dallas
> curl wttr.in/75061?format=%l
75061
is it possible to change the location, but output the more descriptive location info?
As a workaround, if you're only doing a handful of locations/hardcoding it in with whatever you're using to fetch the weather (ie, you're not taking user input and passing that as the location) you can actually add text to the string and have it get returned however.
For example: curl "https://wttr.in/Dallas?format=Weather%20in%20Dallas%2C%20Texas:%20%C+%t+%h+%w+%m+Sunrise:%20%S+Sunset:%20%s"
will return:
Weather in Dallas, Texas: Partly cloudy +76°F 84% ←4mph 🌗 Sunrise: 06:52:56 Sunset: 20:08:33
This isn't as useful if you're having a user specify a location, or if you want %l to work on the fly with any arbitrary location. But if you're just wanting the location to be output properly for a handful of hardcoded locations this is a workaround that I've found useful.
Thanks for the suggestion, but I don't like that. It looks like you can pull the data from JSON using format=j2
:
"nearest_area": [
{
"areaName": [
{
"value": "Dallas"
}
],
"country": [
{
"value": "United States of America"
}
],
"region": [
{
"value": "Texas"
}
]
}
]
however I would rather not have to mess with decoding the JSON if possible.