2

I use Geektool on the Mac to display various information on my desktop. One feature of Geektoool is the ability to use shell mode to launch custom scripts or commands. I am not versed in any type of scripting, but find pieces on the web to use by copying and pasting. There are whole website dedicated to just this.

I have for a long time used a command to pull a one day weather forecast from Weather Underground. However they have changed their site and the output of the script needs to be edited. I am now getting duplicate information being displayed.

Example

Today is forecast to be Cooler than yesterday.
"weather_quickie": "Today is forecast to be Cooler than yesterday."

The script incorporates Textutil for the output.

curl -s http://www.wunderground.com/cgi-bin/findweather/getForecast?query=94965 | 
awk '/Today is/ || /Tomorrow is/' | textutil -convert txt -stdin -stdout -format html

From the man page of textutil, it seems like the option -excludedelements can be used to edit out the extra info. However I can't understand the -excludedelements explanation, nor figure out how to format it.

excludedelements (tag1, tag2, ...) - Specify which HTML elements should not be used in generated HTML (the list should be a single argument, and so will usually need to be quoted in a shell context).

I would like to edit out the "weather_quickie" part of the output. Any insight will be greatly appreciated.

2 Answers 2

1

Thanks for your help Ramesh. It proved too difficult to install w3m. However, based upon your script, I just modified my original and I'm now getting the right output.

Before,

curl -s http://www.wunderground.com/cgi-bin/findweather/getForecast?query=94965 | awk '/Today is/ || /Tomorrow is/' | textutil -convert txt -stdin -stdout -format html

After,

curl ""http://www.wunderground.com/cgi-bin/findweather/getForecast?query=94965"" -s | textutil -convert txt -stdin -stdout -format html | awk '/Today is/'
1
  • Glad that it worked :)
    – Ramesh
    Apr 26, 2014 at 18:16
0

You can use w3m to do this.

curl ""http://www.wunderground.com/cgi-bin/findweather/getForecast?query=94965"" -s |  w3m -dump -T text/html > 1.txt | awk '/Today is/ || /Tomorrow is/' 1.txt

Output

Today is forecast to be Much Cooler than yesterday. Afternoon thundershowers.

3
  • Thanks Ramesh. I was aware I could use a text-based browser, but I'm out of my depth compiling and installing binaries. But I'll search around how to install w3m.
    – Dean
    Apr 25, 2014 at 22:31
  • If you are using debian based systems, you can find it installed by default. It is pretty useful, hope you find it in your machine :)
    – Ramesh
    Apr 25, 2014 at 22:36
  • Running Mac OSX 10.7.5. But I'm following a lead to install w3m. I'm sure I will figure it out!
    – Dean
    Apr 26, 2014 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .