Skip to content

Instantly share code, notes, and snippets.

@0x1d107
Last active September 28, 2023 13:59
Show Gist options
  • Select an option

  • Save 0x1d107/1e10c98c416e51539d4498f1b5e3e747 to your computer and use it in GitHub Desktop.

Select an option

Save 0x1d107/1e10c98c416e51539d4498f1b5e3e747 to your computer and use it in GitHub Desktop.
gismeteo cli
#!/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