Last active
September 28, 2023 13:59
-
-
Save 0x1d107/1e10c98c416e51539d4498f1b5e3e747 to your computer and use it in GitHub Desktop.
gismeteo cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| URL_CACHE="$HOME/.cache/gismeteo" | |
| if [ "$#" -eq 0 ] && [ -r "$URL_CACHE" ] | |
| then | |
| xargs curl -Ls < "$URL_CACHE" |xml sel -t -m '/document/GetHHForecastResult' -v '@cityName' -o ', ' -v '@country_name' -n -t -m '//HHForecast|//HHWeather' -v 'time' -o ' ' -v 't' -o '°C ' -v 'fullDesc' -n | |
| exit; | |
| fi | |
| ENDPOINT="http://c31b3236.services.gismeteo.ru/inform-service" | |
| HASH=$(curl -sL "$ENDPOINT/register/?id=13371" |xml sel -t -v '/document/data/hash') | |
| URL="$ENDPOINT/$HASH" | |
| CITY="${1:-moscow}" | |
| CITY_ID=$(curl -Ls "$URL/cities/?startsWith=$CITY&searchAll=0&lang=en" |xml sel -t -v '/document/data/LocationInfoFull[1]/id') | |
| DATA_URL="$URL/forecast/?city=$CITY_ID&lang=en" | |
| echo -n "$DATA_URL" > "$URL_CACHE" | |
| curl -Ls "$DATA_URL"|xml sel -t -m '/document/GetHHForecastResult' -v '@cityName' -o ', ' -v '@country_name' -n -t -m '//HHForecast|//HHWeather' -v 'time' -o ' ' -v 't' -o '°C ' -v 'fullDesc' -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment