Quero encontrar o clima atual de uma cidade específica ou minha localização no terminal. Existe algum aplicativo meteorológico da linha de comando?
Quero encontrar o clima atual de uma cidade específica ou minha localização no terminal. Existe algum aplicativo meteorológico da linha de comando?
Respostas:
Basta digitar o seguinte em um terminal:
curl wttr.in
E obterá sua localização a partir de /etc/timezone. Caso contrário curl wttr.in/your_location. Por exemplo, para Teerã:
curl wttr.in/tehran
O que lhe dá:

Você também pode comparar duas cidades:
diff -Naur <(curl -s http://wttr.in/london ) <(curl -s http://wttr.in/new-york )
O código fonte do desenvolvedor está disponível no Github .
devsnós dois
Pesquise sua cidade em http://www.accuweather.com e substitua o URL no seguinte script pelo URL da sua cidade:
#!/bin/sh
URL='http://www.accuweather.com/en/de/berlin/10178/weather-forecast/178087'
wget -q -O- "$URL" | awk -F\' '/acm_RecentLocationsCarousel\.push/{print $2": "$16", "$12"°" }'| head -1
Saída de amostra:
Berlin, Germany: Foggy, 1°
acm_RecentLocationsCarousel.push({name:"Berlin, Germany", daypart:'day', href:'/en/de/berlin/10178/weather-forecast/178087', icon:'i-6-l', bg:'c', temp:'0', realfeel:'-6', text:"Mostly cloudy"});. Usando seu código, o awkseparador de campos é '' (espaço). A $12(temperatura) é a 12ª coluna?
awkseparador é '. A API usa 2 números, o primeiro é o postleitzahlou CEP. O segundo parece ser um número de código da API
Eu tenho mais uma maneira.
Abra seu .bashrcarquivo e cole esse código na parte inferior
weather(){ curl -s "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=${@:-<YOURZIPORLOCATION>}"|perl -ne '/<title>([^<]+)/&&printf "%s: ",$1;/<fcttext>([^<]+)/&&print $1,"\n"';}
Em seguida, salve e feche seu .bashrcarquivo.
Agora digite bashpara atualizar o arquivo.
então digite
weather <location name>
por exemplo
august@august-OEM:~$ weather guntur
December 14, 2013: Clear. High 31&deg;C (87&deg;F). Winds 0 kph North
December 15, 2013: Clear. High 29&deg;C (84&deg;F). Winds 10 kph NNW
December 16, 2013: Clear. High 31&deg;C (87&deg;F). Winds 10 kph North
December 17, 2013: Clear. High 29&deg;C (84&deg;F). Winds 7 kph ENE
December 18, 2013: Scattered Clouds. High 29&deg;C (84&deg;F). Winds 3 kph ENE
December 19, 2013: Scattered Clouds. High 29&deg;C (84&deg;F). Winds 3 kph ENE
YOUZIPORLOCATIONcom $1e passar 20001(Washington, DC CEP), fico com linhas que parecem não formatado como Today: Mostly sunny and breezy. Highs in the upper 30s. Northwest winds 20 to 25 mph with gusts up to 45 mph.quando eu uso "washington.dc", eu recebo saída da tabela May 4, 2015: Clear. High 32&deg;C (89&deg;F). Winds 43 kph East. Alguma idéia do porquê da diferença?
Aqui está um ótimo utilitário de linha de comando semi-gráfico escrito em Go:
https://github.com/schachmat/wego/
Você precisará instalar o Go e configurar algumas coisas da API, mas as instruções estão lá. Aqui está uma foto de amostra:

curl wttr.iné suficiente
curl wttr.in/Helsinki?m
Tente usar
telnet rainmaker.wunderground.com
Primeiro você precisa instalar o pacote weather-util, para isso basta pressionar Ctrl+ Alt+ Tno teclado para abrir o Terminal. Quando abrir, execute o (s) comando (s) abaixo:
sudo apt-get install weather-util
Você precisará do seu código climático local .
Após a instalação, você pode executar weather -i <code>. O código que você obtém no link acima. Para obter uma lista de opções disponíveis, você pode executar as weatherinformações do tempo
Last updated Dec 11, 2013 - 07:00 AM EST / 2013.12.11 1200 UTC Temperature: 86 F (30 C)não há como saber o tempo atual.
weather YOURLOCATIONNAMEele procura sua localização e fornece possivelmente vários resultados. A partir dessas você pode ler o identificador da estação que você pode usar como argumento para buscar suas informações de tempo da
weather LAX(que deve mostrar o clima para o Aeroporto Internacional de Los Angeles) mostra um erro 404 para weather.noaa.gov/pub/data/observations/metar/decoded/KNKX.TXT
http://weather.noaa.gov/pub/datapara http://tgftp.nws.noaa.gov/data. UPDATE: Parece que eles já o corrigiram na versão 2.1, que você pode obter no site do projeto .
ansiweather
AnsiWeather é um script do Shell para exibir as condições climáticas atuais em seu terminal, com suporte para cores ANSI e símbolos Unicode. Os dados meteorológicos são provenientes da API de tempo livre do OpenWeatherMap.
sudo apt-get install ansiweather
ansiweather -l London,GB -f 3
London forecast => Sat Jan 13: 7/2 °C ☔ - Sun Jan 14: 4/1 °C ☔ - Mon Jan 15: 9/6 °C ☔
também um programa que vem pré-instalado com o ubuntu chamado inxi fornecerá todos os tipos de estatísticas no seu computador e produz uma previsão do tempo.
comando: inxi --help
comando: inxi -w
Conditions: 82 F (28 C) - Clear Time: May 13, 10:52 AM CDT
comando: inxi -wxxx
Conditions: 82 F (28 C) - Clear Wind: From the SW at 13 MPH Humidity: 60%
Pressure: 29.99 in (1016 mb) Heat Index: 84 F (29 C)
Location: city (USA) Altitude: 185 m
Time: May 13, 10:52 AM CDT (America/Chicago) Observation Time: May 13, 9:54 AM CDT
sudo apt install inxi
inxiestá disponível, mas você precisa ativar o repositório do universo primeiro.
Você pode comparar cidades usando:
diff -Naur <(curl -s http://wttr.in/london ) <(curl -s http://wttr.in/new-york )
conforme ilustrado na resposta mais votada. wttr.intambém cria uma ótima tela "splash" toda vez que você abre o terminal. Faça isso adicionando-o ao seu ~/.bashrcarquivo. Fiz isso para incluir informações sobre clima, data, hora e distribuição, conforme detalhado nesta resposta: Como posso obter essa tela inicial do terminal?
Desculpe, eu estava no Ubuntu no Windows 10 WSL para atualizações da Primavera de 2018 quando capturei esta imagem. Prometa que inicializarei novamente o Ubuntu no Linux em breve.
Para resultados climáticos ainda mais curtos, http://weather.tuxnet24.de fornece dados climáticos do Yahoo! em formato de texto e xml.
Os campos do XML podem ser obtidos com um analisador de XML como xmllint, ie.
Eu escrevi um script de busca e busca de clima, que obtém a temperatura atual e a descrição do clima, em seguida, armazena um símbolo unicode correspondente à descrição e a gera como
☂ 6 ° C
Eu atualizo regularmente via cronjob e depois uso a saída no status da minha bandeja.
Obtenha seu ID em yahoocom / news / weather. Altere o local para o local desejado e procure o ID no URL (ou seja, se o URL for yahoocom / news / weather / germany / north-rhine-westphalia / bielefeld-20066057, o ID é 20066057).
O XML contém outros campos, como dados de previsão, vento etc. - você também pode analisá-los, se desejar.
Infelizmente alguns símbolos climáticos não estão representados no Ubuntufont ... sinta-se à vontade para ajustar.
Aqui está o meu script (substitua 20066057 pelo seu ID, se você não mora em Bielefeld) - depende do bash, curl e xmllint.
#!/bin/sh
#☁☂☔❄❅❆☃ ☀☁☂⚡⚐☼
# write xml to variable
w_xml=$(curl -Ls "http://weather.tuxnet24.de/?id=20066057&mode=xml");
# get fields from xml via xmllint | xargs for trimming
# weather description
w_txt=$(xmllint --xpath "string(//current_text)" - <<<"$w_xml" | xargs);
# temperature | remove spaces from text (°C prepended by space)
w_tpc=$(xmllint --xpath "string(//current_temp)" - <<<"$w_xml" | xargs); w_tpc=${w_tpc//[[:blank:]]/};
# further fields not used atm
# w_tph=$(xmllint --xpath "string(//current_temp_high)" - <<<"$w_xml" | xargs);
# w_tpl=$(xmllint --xpath "string(//current_temp_low)" - <<<"$w_xml" | xargs);
# set $w_sym according to $w_txt
if [ "$w_txt" == "Sunny" ]; then w_sym="☼";
elif [ "$w_txt" == "Mostly Sunny" ]; then w_sym="☼";
elif [ "$w_txt" == "Showers" ]; then w_sym="☂";
elif [ "$w_txt" == "Clear" ]; then w_sym="☾";
elif [ "$w_txt" == "Thunderstorms" ]; then w_sym="⚡";
elif [ "$w_txt" == "Scattered Thunderstorms" ]; then w_sym="☔";
elif [ "$w_txt" == "Isolated Thundershovers" ]; then w_sym="☔";
elif [ "$w_txt" == "Cloudy" ]; then w_sym="☁";
elif [ "$w_txt" == "Mostly Cloudy" ]; then w_sym="☁";
elif [ "$w_txt" == "Partly Cloudy" ]; then w_sym="☼☁";
elif [ "$w_txt" == "Breezy" ]; then w_sym="⚐";
# if unknown text, set text instead of symbol
else w_sym=$w_txt;
fi
# output <symbol><space><temp-in-°C>
echo "$w_sym"" ""$w_tpc";
#!/usr/bin/env bashcorrigido para mim, Ubuntu 18.04
Eu tenho mais uma maneira.
Abra o arquivo .bashrc e cole esse código na parte inferior
test -f ~/.wttr.in || curl -sk wttr.in -o ~/.wttr.in
find ~ -maxdepth 1 -name .wttr.in -cmin +5 -exec curl -sk wttr.in -o ~/.wttr.in \;
head -7 ~/.wttr.in | tail -5
W(){ find ~ -maxdepth 1 -name .wttr.in -cmin +5 -exec curl -sk wttr.in -o ~/.wttr.in \;; head -27 ~/.wttr.in; }
Salve e feche seu .bashrcarquivo e execute o seguinte comando para atualizar o bash:
. .bashrc
depois digite Wmaiúsculas
.bashrcarquivo. Você pode executar: source .bashrcou você pode executar isto:. .bashrc
Embora a solução accuweather curl seja muito boa, eu precisava de algo mais informativo, por isso criei um script simples que extrai informações pelas próximas 4 horas do site weather.com. Como no exemplo anterior, você precisa modificar o link para sua localização.
Example output:
$ ./getWeather.sh
Temperature for 1 AM : 65°F and outside should be: Partly - Cloudy FEELS LIKE: 65°
Temperature for 2 AM : 65deg;F and outside should be: Partly - Cloudy FEELS LIKE: 65deg;
Temperature for 3 AM : 63deg; and outside should be: Partly - Cloudy FEELS LIKE: 63deg;
Temperature for 4 AM : 62deg; and should be: Mostly - Clear FEELS LIKE: 62deg;
O script completo está localizado em: https://sites.google.com/site/wozoopalinux/home/wzbash001/get-weather-information-from-command-line-for-next-4-hrs
finger city_name@graph.no
$ finger cologne@graph.no
-= Meteogram for germany/north_rhine-westphalia/cologne =-
'C Rain
16
15 ^^^
14 ======^^^ ^^^
13 === ^^^===^^^===
12 =========
11 === ====--
10 ====== ---
9=====| --- 3 mm
8 | | 2 mm
7 | | | | | | | | | | | | | | 1 mm
_08_09_10_11_12_13_14_15_16_17_18 19 20 21 22 23 00 01 02 03 04 05 Hour
SE SE SE SE SE SW SW W W W W SW W W W W W NW NW NW N N Wind dir.
5 5 5 5 4 4 5 6 6 6 5 5 5 4 4 5 5 5 4 3 3 3 Wind(mps)
Legend left axis: - Sunny ^ Scattered = Clouded =V= Thunder # Fog
Legend right axis: | Rain ! Sleet * Snow
[Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.]
Aqui está como usá-lo:
$ finger help@graph.no
yr.no is having technical problems, or you specified an unknown location.
Usage:
* finger <city name>@graph.no (world weather forecast, no spaces)
Example: finger newyork@graph.no
Advanced usage:
* finger o:<city name>@graph.no (a one-line forecast)
Example: finger o:newyork@graph.no
* finger ^<city name>@graph.no (Imperial units)
Example: finger ^newyork@graph.no
* finger <city name>+5@graph.no (forecast from 5 hrs ahead in time (max:26))
Example: finger northpole+5@graph.no
* finger <city name>~160@graph.no (set screen width)
Example: finger southpole~160@graph.no
* finger <city name>%2@graph.no (forecast for every second hour [Norway])
Example: finger oslo%2@graph.no
* finger <post code>@graph.no (norwegian weather forecast)
Example: finger 0458@graph.no
Other:
* finger news@graph.no (latest headlines from NRK)
* finger time@graph.no (server local time)
* finger date@graph.no (server local date)
* finger about@graph.no (contact information)
International names comes from http://fil.nrk.no/yr/viktigestader/verda.txt.
A história por trás disso do desenvolvedor.