Wttr.in: Text only output

Created on 18 May 2017  Â·  5Comments  Â·  Source: chubin/wttr.in

Can there be an option for a text only output?

I would like this:

Weather report: Broadstairs, United Kingdom
      .-.      Moderate rain
     (   ).    12-13 °C       
    (___(__)   ↘ 12 km/h      
   ‚‘‚‘‚‘‚‘    13 km          
   ‚’‚’‚’‚’    3.0 mm 

To become this:

Weather report: Broadstairs, United Kingdom
Summery: Moderate rain
Temp: 12-13 °C       
Wind: South East 12 km/h      
13 km   (I don't know what this is!)       
Rainfall: 3.0 mm 

Can it be done?

enhancement

Most helpful comment

I don't pretend for the best decision but in bash maybe something like this:
curl wttr.in 2>&1 | grep -A 6 "Weather report" | sed '1,2d' |sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"| sed -E 's/^.{15}//'

  1. curl wttr.in 2>&1 the main idea of this task is that curl send output to stderr(2), so to change output you need redirect it to stdout(1)
  2. grep -A 6 "Weather report" find the line with "Weather report" and shows 6 lines below (including our occurrence line)
  3. sed '1,2d' delete first two string
  4. sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" remove colors
  5. sed -E 's/^.{15}//' Erase first 15 symbols(seems like all ascii pictures that they have always 15 symbols length)

Here is my output:
Sunny
-8--2 °C
↑ 22 km/h
10 km
0.1 mm

All 5 comments

I also like to see something like this. This comes in handy when using the information wttr.in provides in other scripts. It is easier to sed the temperature for example when there are no special chars (which also change depending on the ascii art).

13 km (I don't know what this is!

According to https://github.com/schachmat/wego

temperature range (felt and measured)
windspeed and direction
viewing distance
precipitation amount and probability

It's viewing distance (at the moment).
But please keep in mind that wttr.in and wego have diverged, so in some cases (but not in this case) some wttr.in and wego fields may have a different meaning.

I don't pretend for the best decision but in bash maybe something like this:
curl wttr.in 2>&1 | grep -A 6 "Weather report" | sed '1,2d' |sed "s,\x1B\[[0-9;]*[a-zA-Z],,g"| sed -E 's/^.{15}//'

  1. curl wttr.in 2>&1 the main idea of this task is that curl send output to stderr(2), so to change output you need redirect it to stdout(1)
  2. grep -A 6 "Weather report" find the line with "Weather report" and shows 6 lines below (including our occurrence line)
  3. sed '1,2d' delete first two string
  4. sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" remove colors
  5. sed -E 's/^.{15}//' Erase first 15 symbols(seems like all ascii pictures that they have always 15 symbols length)

Here is my output:
Sunny
-8--2 °C
↑ 22 km/h
10 km
0.1 mm

A simple way to do it

curl 'wttr.in?0TF' 2>&1 |sed -E 's/^.{15}//'m

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natehouk picture natehouk  Â·  4Comments

andy-twosticks picture andy-twosticks  Â·  5Comments

mdigga39 picture mdigga39  Â·  4Comments

532910 picture 532910  Â·  7Comments

Quenty-tolosan picture Quenty-tolosan  Â·  9Comments