Hey! Want to get some news from your favorite news websites w/o click your web browser ? Try to do in this way, and hope it will not interrupt your boring work. Ccc...
FIRST, you shall write a simple shell script to parse the news RSS pages from your favorite news website.
$ cat myUdnRss.sh#!/bin/sh
DL_URL="http://udn.com/udnrss/latest.xml"
#DL_URL="http://rss.chinatimes.com/rss/focus-u.rss"
FILE_SAVED="/tmp/latest.htm"
FILE_PARSED="/tmp/latest.out"
LOGO="/home/yenping/myJob/udn.jpg"
if [ $# -gt 0 ]; then
DL_URL=$1
fi
if [ $# -gt 1 ]; then
LOGO=$2
fi
wget $DL_URL -O $FILE_SAVED
##
cat $FILE_SAVED | sed -n -e '/title/p' -e '/des/p' | sed -e 's/CDATA\[/\>/' -e 's/\]/\]*>//g;/ $FILE_PARSED
##cat $FILE_SAVED | sed -n -e '/title/p' -e '/des/p' | sed -e :a -e 's/<[^>]*>//g;/ $FILE_PARSED
##iconv --from-code=Big-5 --to-code=UTF-8 $FILE_PARSED > $FILE_PARSED.2
cat $FILE_PARSED | while read title && read description; do notify-send "$title" "$description"`date +%H:%M` -i $LOGO; done
DL_URL="http://udn.com/udnrss/latest.xml"
#DL_URL="http://rss.chinatimes.com/rss/focus-u.rss"
FILE_SAVED="/tmp/latest.htm"
FILE_PARSED="/tmp/latest.out"
LOGO="/home/yenping/myJob/udn.jpg"
if [ $# -gt 0 ]; then
DL_URL=$1
fi
if [ $# -gt 1 ]; then
LOGO=$2
fi
wget $DL_URL -O $FILE_SAVED
##
cat $FILE_SAVED | sed -n -e '/title/p' -e '/des/p' | sed -e 's/CDATA\[/\>/' -e 's/\]/\]*>//g;/ $FILE_PARSED
##cat $FILE_SAVED | sed -n -e '/title/p' -e '/des/p' | sed -e :a -e 's/<[^>]*>//g;/ $FILE_PARSED
##iconv --from-code=Big-5 --to-code=UTF-8 $FILE_PARSED > $FILE_PARSED.2
cat $FILE_PARSED | while read title && read description; do notify-send "$title" "$description"`date +%H:%M` -i $LOGO; done
------------------------------------------------------------------
Note:
* sed is used to parse the RSS pages per your demands.
** some pages need to be converted from different encodings.
$ crontab -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/yenping/myJob
# m h dom mon dow command
#*/1 * * * * env DISPLAY=:0 /home/yenping/workspace/noti01.sh
0 12 * * * env DISPLAY=:0 /usr/bin/notify-send 'Stomach' 'Time to eat !' -i /usr/share/pixmaps/gnome-gmush.png
0 18 * * * env DISPLAY=:0 /usr/bin/notify-send 'Foot' 'Time to go !' -i /usr/share/pixmaps/faces/sunset.jpg
0 * * * * env DISPLAY=:0 /usr/bin/notify-send `date +\%H:\%M` -i /usr/share/pixmaps/gnome-set-time.png
15,45 * * * * env DISPLAY=:0 myUdnRss.sh http://udn.com/udnrss/latest.xml
00,30 * * * * env DISPLAY=:0 myUdnRss.sh http://rss.chinatimes.com/rss/focus-u.rss /home/yenping/myJob/chinatimes.jpg
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/yenping/myJob
# m h dom mon dow command
#*/1 * * * * env DISPLAY=:0 /home/yenping/workspace/noti01.sh
0 12 * * * env DISPLAY=:0 /usr/bin/notify-send 'Stomach' 'Time to eat !' -i /usr/share/pixmaps/gnome-gmush.png
0 18 * * * env DISPLAY=:0 /usr/bin/notify-send 'Foot' 'Time to go !' -i /usr/share/pixmaps/faces/sunset.jpg
0 * * * * env DISPLAY=:0 /usr/bin/notify-send `date +\%H:\%M` -i /usr/share/pixmaps/gnome-set-time.png
15,45 * * * * env DISPLAY=:0 myUdnRss.sh http://udn.com/udnrss/latest.xml
00,30 * * * * env DISPLAY=:0 myUdnRss.sh http://rss.chinatimes.com/rss/focus-u.rss /home/yenping/myJob/chinatimes.jpg
------------------------------------------------------------------
FINALLY, when the time being, the parsed news show up in the notify window. :)
沒有留言:
張貼留言