Wttr.in
De Mi caja de notas
Révision datée du 6 février 2019 à 10:07 par Xtof (discussion | contributions) (Page créée avec « http://wttr.in source https://github.com/chubin/wttr.in *wttr.in — la bonne façon de vérifier la météo !* wttr.in est un service orienté-console de prévision... »)
source https://github.com/chubin/wttr.in
- wttr.in — la bonne façon de vérifier la météo !*
wttr.in est un service orienté-console de prévision météo qui supporte différentes méthodes de représentation comme les séquences-ANSI-orientées-terminal pour les clients HTTP de console (curl, httpie, or wget), HTML pour les navigateurs web browsers, ou PNG pour les visualiser graphiques.
wttr.in utilise [wego](http://github.com/schachmat/wego) pour la visualisation et les différentes sources de données pour la prévision d'info météo.
Vous pouvez le voir en fonctionnement en lançant : [wttr.in](http://wttr.in).
Usage
Accédez au service à partir de la ligne de commande ou à partir d'un navigateur web comme ceci :
$ curl wttr.in Weather for City: Paris, France
\ / Clear .-. 10 – 11 °C ― ( ) ― ↑ 11 km/h `-’ 10 km / \ 0.0 mm
Here is an actual weather report for your location (it's live!):
![Weather Report](http://wttr.in/MyLocation.png?)
(It's not your actual location - GitHub's CDN hides your real IP address with its own IP address, but it's still a live weather report in your language.)
Want to get the weather information for a specific location? You can add the desired location to the URL in your request like this:
$ curl wttr.in/London $ curl wttr.in/Moscow
Si vous omettez le nom du lieu, vous obtiendrez le rapport pour votre lieu actuel basé sur votre adresse IP.
Utilisez les codes aéroport à 3 lettres afin de recevoir l'information météo pour un certain aéroport :
$ curl wttr.in/muc # Weather for IATA: muc, Munich International Airport, Germany $ curl wttr.in/ham # Weather for IATA: ham, Hamburg Airport, Germany
Let's say you'd like to get the weather for a geographical location other than a town or city - maybe an attraction in a city, a mountain name, or some special location. Add the character `~` before the name to look up that special location name before the weather is then retrieved:
$ curl wttr.in/~Vostok+Station $ curl wttr.in/~Eiffel+Tower $ curl wttr.in/~Kilimanjaro
For these examples, you'll see a line below the weather forecast output that shows the geolocation results of looking up the location:
Location: Vostok Station, станция Восток, AAT, Antarctica [-78.4642714,106.8364678]
Location: Tour Eiffel, 5, Avenue Anatole France, Gros-Caillou, 7e, Paris, Île-de-France, 75007, France [48.8582602,2.29449905432]
Location: Kilimanjaro, Northern, Tanzania [-3.4762789,37.3872648]
You can also use IP-addresses (direct) or domain names (prefixed with `@`) to specify a location:
$ curl wttr.in/@github.com $ curl wttr.in/@msu.ru
To get detailed information online, you can access the [/:help](http://wttr.in/:help) page:
$ curl wttr.in/:help
Unités Météo
By default the USCS units are used for the queries from the USA and the metric system for the rest of the world. You can override this behavior by adding `?u` or `?m` to a URL like this:
$ curl wttr.in/Amsterdam?u $ curl wttr.in/Amsterdam?m
Formats de sortie supportés
wttr.in currently supports three output formats:
- ANSI for the terminal;
- ANSI for the terminal, one-line mode;
- HTML for the browser;
- PNG for the graphical viewers.
The ANSI and HTML formats are selected basing on the User-Agent string. The PNG format can be forced by adding `.png` to the end of the query:
$ wget wttr.in/Paris.png
You can use all of the options with the PNG-format like in an URL, but you have to separate them with `_` instead of `?` and `&`:
$ wget wttr.in/Paris_0tqp_lang=fr.png
Options utiles pour le format PNG :
- `t` for transparency (`transparency=150`);
- transparency=0..255 for a custom transparency level.
Transparency is a useful feature when weather PNGs are used to add weather data to pictures:
$ convert source.jpg <( curl wttr.in/Oymyakon_tqp0.png ) -geometry +50+50 -composite target.jpg
In this example:
- `source.jpg` - source file;
- `target.jpg` - target file;
- `Oymyakon` - name of the location;
- `tqp0` - options (recommended).
![Image avec données météo](https://pbs.twimg.com/media/C69-wsIW0AAcAD5.jpg)
Sortie en une-ligne
For one-line output format, specify additional URL parameter `format`:
``` $ curl wttr.in/Paris?format=3 Paris: 🌦 +4⁰C ```
Formats disponibles pré-configurés : 1, 2, 3, 4 et format personnalisé en utilisant une note en pourcentage.
Phases de la lune
wttr.in peut être aussi utilisé pour vérifier la phase de la Lune. Cet exemple présente comme voir la phase de la lune en cours :
$ curl wttr.in/Moon
Recevez la phase de la lune pour une date particulière en ajoutant `@AAAA-MM-JJ`:
$ curl wttr.in/Moon@2016-12-25
L'information de la phase de la Lune utilise [pyphoon](https://github.com/chubin/pyphoon) pour son backend.
Internationalisation et localisation
wttr.in prend en charge les noms de lieux en plusieurs langues qui peuvent être spécifiés dans toute langue dans le monde. (ce peut être surprenant mais plein de lieux dans le monde n'ont pas de nom en anglais). (it may be surprising, but many locations in the world don't have an English name).
La chaîne de requête devrait être spécifié en Unicode (encodé-hex ou pas). Les espaces dans la chaîne de requête doivent être remplacés par `+` :
$ curl wttr.in/станция+Восток Weather report: станция Восток
Overcast .--. -65 – -47 °C .-( ). ↑ 23 km/h (___.__)__) 15 km 0.0 mm
The language used for the output (except the location name) does not depend on the input language and it is either English (by default) or the preferred language of the browser (if the query was issued from a browser) that is specified in the query headers (`Accept-Language`).
The language can be set explicitly when using console clients by using command-line options like this:
curl -H "Accept-Language: fr" wttr.in http GET wttr.in Accept-Language:ru
The preferred language can be forced using the `lang` option:
$ curl wttr.in/Berlin?lang=de
The third option is to choose the language using the DNS name used in the query:
$ curl de.wttr.in/Berlin
wttr.in is currently translated into 54 languages, and the number of supported languages is constantly growing.
See [/:translation](http://wttr.in/:translation) to learn more about the translation process, to see the list of supported languages and contributors, or to know how you can help to translate wttr.in in your language.
![Queries to wttr.in in various languages](https://pbs.twimg.com/media/C7hShiDXQAES6z1.jpg)
Installation
Pour installer l'application :
1. Installez les dépendances externes 2. Installez les dépendances Python utilisées par le service 3. Recevez une Clé API WorldWeatherOnline 4. Configurez wego 5. Configurez wttr.in 6. Configurez le service frontend-HTTP
Installez les dépendances externes
wttr.in has the following external dependencies:
- [golang](https://golang.org/doc/install), wego dependency
- [wego](https://github.com/schachmat/wego), weather client for terminal
After you install [golang](https://golang.org/doc/install), install `wego`:
$ go get -u github.com/schachmat/wego $ go install github.com/schachmat/wego
Installez les dépendances Python
Python requirements:
- Flask
- geoip2
- geopy
- requests
- gevent
If you want to get weather reports as PNG files, you'll also need to install:
- PIL
- pyte (>=0.6)
- necessary fonts
You can install most of them using `pip`.
If `virtualenv` is used:
$ virtualenv ve $ ve/bin/pip install -r requirements.txt $ ve/bin/pip bin/srv.py
Also, you need to install the geoip2 database. You can use a free database GeoLite2 that can be downloaded from (http://dev.maxmind.com/geoip/geoip2/geolite2/).
Recevez une clé WorldWeatherOnline
To get a WorldWeatherOnline API key, you must register here:
https://developer.worldweatheronline.com/auth/register
Configurez wego
After you have a WorldWeatherOnline key, you can configure `wego`:
$ cat ~/.wegorc { "APIKey": "00XXXXXXXXXXXXXXXXXXXXXXXXXXX", "City": "London", "Numdays": 3, "Imperial": false, "Lang": "en" }
The `City` parameter in `~/.wegorc` is ignored.
Configurez wttr.in
Configure the following environment variables that define the path to the local `wttr.in` installation, to the GeoLite database, and to the `wego` installation. For example:
export WTTR_MYDIR="/home/igor/wttr.in" export WTTR_GEOLITE="/home/igor/wttr.in/GeoLite2-City.mmdb" export WTTR_WEGO="/home/igor/go/bin/wego" export WTTR_LISTEN_HOST="0.0.0.0" export WTTR_LISTEN_PORT="8002"
Configurez le service frontend-HTTP
It's recommended that you also configure the web server that will be used to access the service:
server { listen [::]:80; server_name wttr.in *.wttr.in; access_log /var/log/nginx/wttr.in-access.log main; error_log /var/log/nginx/wttr.in-error.log;
location / { proxy_pass http://127.0.0.1:8002;
proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr;
client_max_body_size 10m; client_body_buffer_size 128k;
proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90;
proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;
expires off; } }