Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Lynx with GeekTool to grab news headlines Internet
Like many have previously mentioned, GeekTool is a pretty handy little thing (see here, here and here for some good examples). But I was interested in using it with Lynx, a text-based command line web browser -- most easily available from the guys at Fink. Lynx is a great app if your boss can be convinced you're hard at work when he sees a black and white screen full of letters and numbers. But Lynx is by default interactive -- not much use when you can only look at output through GeekTool, so I created the following Script job in Geek tool:
/sw/bin/lynx -dump -width=160 -nolist http://news.bbc.co.uk/text_only.stm
Set this job to run every five minutes or so, and now I've got up-to-the-minute news headlines available just an Exposé command away.

However, the dump file is still kinda large, and I'm not so urgently interested in what's happening in Wales as I am in what's happening on my own doorstep, so I created the following script:
#!/bin/bash

TMPFILE=/tmp/bbcheadlines.tmp
WEBSITE=http://news.bbc.co.uk/text_only.stm
CUTOFF="^[^w]*____"

/sw/bin/lynx -dump $WEBSITE >$TMPFILE

for param in $@
do
  cat $TMPFILE | sed -n '/^ *'$param'/,/'$CUTOFF'/p' | sed '$d'
  echo 
done
This script grabs the $WEBSITE and writes it to a file (chosen by $TMPFILE). It then loops through my parameters, using sed to check for sections that begin with the parameter and end with $CUTOFF, writing the results to sysout. Saving this script as headlines.sh to my home directory, I needed only to put the following job into GeekTool:
/Users/myhomedir/headlines.sh SPORT EUROPE POLITICS
And voila! Customised news headlines on my desktop every five minutes. The script will obviously need some customising for your own favourite websites (anyone want to come up with a good one for MacOSXHints?), but I thought I'd just put the idea out there.
    •    
  • Currently 4.00 / 5
  You rated: 4 / 5 (5 votes cast)
 
[14,659 views]  

Use Lynx with GeekTool to grab news headlines | 6 comments | Create New Account
Click here to return to the 'Use Lynx with GeekTool to grab news headlines' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Lynx with GeekTool to grab news headlines
Authored by: merlyn on Aug 23, '04 01:06:55PM
Hmm.

cat $TMPFILE | ...
And here we have an example of a useless use of cat.

[ Reply to This | # ]
How about using cURL instead?
Authored by: jecwobble on Aug 23, '04 03:10:04PM

Seems like cURL is a more suited choice than lynx in this application.



[ Reply to This | # ]
How about using cURL instead?
Authored by: murphyman on Aug 23, '04 07:30:56PM

I didn't think cURL could format and parse HTML - that's why I used Lynx. Lynx parses the HTML into a readable format - thus this could be applied to any html document. If cURL can be put to such a use, I'd like to be enlightened



[ Reply to This | # ]
using cURL to grab slashdot headlines.
Authored by: andersea on Nov 22, '04 06:54:56PM
I've written a quick script that will grab Slashdot's headlines for geektool using curl grep and sed. Check out the one liner here.

[ Reply to This | # ]
Use Lynx with GeekTool to grab news headlines
Authored by: jbc on Aug 23, '04 03:54:16PM

I was just playing around with this idea yesterday, but I'm using MkConsole rather than Geektool. Started out trying to use snownews to grab RSS feeds, but like jecwobble, eventually decided curl was the easiest tool to use. You can pipe the output through any shell/sed/awk/perl script you care to create to filter/format the final output to file.



[ Reply to This | # ]
Use Lynx with GeekTool to grab news headlines
Authored by: bluehz on Aug 23, '04 06:06:53PM

You might want to take a look at this script also

http://www.intuitive.com/wicked/showscript.cgi?060-bbcnews.sh

from the book Wicked Cool Shell Scripts (Dave Taylor) which is an excellent book with lots of great scripts. The scripts are completely free and listed online here:

http://www.intuitive.com/wicked/wicked-cool-shell-script-library.shtml

[ Reply to This | # ]