5 Cent tip for today [ RSS Menu based ]

Started by newdep, July 24, 2004, 12:25:27 PM

Previous topic - Next topic

newdep

Oke oke.. i cant stop so here my RSS tilte menu version,

its simple but functional, enjoy and explore...



#!/usr/bin/newlisp

;;

;; RSS Title Slurp - (c) Norman 2004

;; version 3.0 Menu version

;; Linux Console version

;;



(set 'channel '( "title" "pubDate" ))



;;

;; Manual to add --> ( Number Site description link )

;;

(set 'uri '(

("00" "NU.NL  " "Algemeen"                                                      "http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen">http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen")

("01" "NU.NL  " "Internet"                                                      "http://nu.nl/deeplink_rss2/index.jsp?r=Internet">http://nu.nl/deeplink_rss2/index.jsp?r=Internet")

("02" "NU.NL  " "Economie"                                                      "http://nu.nl/deeplink_rss2/index.jsp?r=Economie">http://nu.nl/deeplink_rss2/index.jsp?r=Economie")

("03" "NU.NL  " "Achterklap"                                                    "http://nu.nl/deeplink_rss2/index.jsp?r=Achterklap">http://nu.nl/deeplink_rss2/index.jsp?r=Achterklap")

("04" "NU.NL  " "Sport"                                                         "http://nu.nl/deeplink_rss2/index.jsp?r=Sport">http://nu.nl/deeplink_rss2/index.jsp?r=Sport")

("05" "NU.NL  " "Yoshe"                                                         "http://nu.nl/deeplink_rss2/index.jsp?r=Yoshe">http://nu.nl/deeplink_rss2/index.jsp?r=Yoshe")

("06" "NEWLISP" "News"                                                          "http://newlisp.org/rss.cgi?News">http://newlisp.org/rss.cgi?News")

("07" "YAHOO  " "Linux"                                                         "http://rss.news.yahoo.com/rss/linux">http://rss.news.yahoo.com/rss/linux")

("08" "YAHOO  " "CellPhones"                                                    "http://rss.news.yahoo.com/rss/cellphones">http://rss.news.yahoo.com/rss/cellphones")

("09" "YAHOO  " "Science"                                                       "http://rss.news.yahoo.com/rss/science">http://rss.news.yahoo.com/rss/science")

("10" "VPRO   " "Aanbevolen films deze week in de bioscoop"                     "http://www.vpro.nl/cinema/binders/rss/index.jsp">http://www.vpro.nl/cinema/binders/rss/index.jsp")

("11" "VPRO   " "Aanbevolen films vandaag op televisie (de Cinema.nl selectie)" "http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp?pools=8043634">http://www.vpro.nl/cinema/includes_tele ... ls=8043634">http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp?pools=8043634")

("12" "VPRO   " "Alle films vandaag op televisie"                               "http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp">http://www.vpro.nl/cinema/includes_tele ... /index.jsp">http://www.vpro.nl/cinema/includes_televisie/rss/index.jsp")

("13" "VPRO   " "Alle nieuwe berichten"                                         "http://www.vpro.nl/cinema/magazines/rss/index.jsp">http://www.vpro.nl/cinema/magazines/rss/index.jsp")

("14" "VPRO   " "Nieuwe recensies"                                              "http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=1">http://www.vpro.nl/cinema/magazines/rss ... newstype=1">http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=1")

("15" "VPRO   " "Nieuwe dvdrecensies"                                           "http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=11">http://www.vpro.nl/cinema/magazines/rss ... ewstype=11">http://www.vpro.nl/cinema/magazines/rss/index.jsp?newstype=11")

("16" "NEWLISP" "Blog Demo Site"                                                "http://newlisp.org/blog/rss.cgi">http://newlisp.org/blog/rss.cgi")

))







;;

(define (banner) (println (dotimes ( x 79 ) (print "*"))  ))

(define (cls)     (println "27[H27[2J"))



(until (net-error)

        ;;

        ;; Print Menu selection

        ;;

        (cls)

        (banner)

        (println "** RSS TITLE SLURPER - NODEP 2004")

        (banner)

        (println)

        (dolist (item uri)

                (println "[ " (nth 0 item) " ]  " (nth 1 item) " -> " (nth 2 item)))

        (println)

        (banner)

        (print "** RSS Feed number: ")



        (unless (set 'choice (integer (read-line)))

                (begin

                (println "** RSS Quited...")

                (exit)))



        (set 'url (nth 3 (nth choice uri) ))



        ;;

        ;; DE-XML

        ;;

        (xml-type-tags nil 'cdata '!-- nil)

        (set 'url (xml-parse (get-url url) (+ 1 2 8 16) ))



        ;;

        ;; strippp <!-- comments from top...

        ;;

        (until (= (first (nth 0 url)) 'rss ) (pop url))



        (set 'rsschannel (nth 2 (nth 0 url)))

        (set 'rsschannellen (length rsschannel))



        (cls)

        (banner)



        ;;

        ;; Channel info -> Required CHANNEL elements: title link description

        ;;

        (dolist (x channel)

                (if (set 'element (lookup (symbol x) rsschannel))

                (println "** RSS Channel " x " -> " element )))



        (banner)





        ;;

        ;; Seeking for ITEMS in CHANNEL

        ;;

        (dotimes (y rsschannellen)

         (if (list? (nth y rsschannel))

          (if (= (nth 0 (nth y rsschannel)) 'item )

           (println "** RSS Item -> " (lookup 'title (nth y rsschannel))))))



        (banner)

        (println "** Press <enter> for Menu")

        (banner)

        (read-line)



)

(exit)
-- (define? (Cornflakes))

Lutz

#1
rss ticker and menu are fantastic! thanks!



Lutz

newdep

#2
All the scripts are now on http://www.nodep.nl/newlisp">http://www.nodep.nl/newlisp
-- (define? (Cornflakes))

Lutz

#3
And here the only newLISP program you ever need to write, and get all the rest from Norman:



#!/usr/bin/newlisp
#
# get all of Norman's utilities at once
#
# - lutz
#

(set 'page (get-url "http://www.nodep.nl/newlisp/index.html"))
(replace {href="(http://.*lsp)"} page (push $1 links) 0)

(dolist (link links)
  (set 'file (last (parse link "/")))
      (write-file file (get-url link))
(println "->" file))


(exit)

;; eof ;;


Lutz

newdep

#4
hahaha like that one ;-)
-- (define? (Cornflakes))