För Chicken Scheme och wget.
Logga in på WRNU med Lynx och spara kakorna i ~/wrnu-cookie.file (behöver bara göras en gång).
Chmodda om den filen till 700 så ingen kan snoka ditt lösen.
Git kan ni hitta här git clone https://idiomdrottning.org/wrnualert
Eller klistra in koden från nedan:
Logga in på WRNU med Lynx och spara kakorna i ~/wrnu-cookie.file (behöver bara göras en gång).
Chmodda om den filen till 700 så ingen kan snoka ditt lösen.
Git kan ni hitta här git clone https://idiomdrottning.org/wrnualert
Eller klistra in koden från nedan:
Code:
(import html-parser shell sxpath sxml-transforms sxml-serializer (chicken pretty-print) (chicken string) srfi-1 srfi-42)
(run (wget --load-cookies ~/wrnu-cookie.file -O /tmp/alerts https://www.rollspel.nu/account/alerts))
(define alerts ((sxpath "//ol/li") (with-input-from-file "/tmp/alerts" html->sxml)))
(define (entry-date e)
(cadar ((sxpath "//@datetime") e)))
(define (url-complete str)
(if (substring=? "data:" str)
str
(string-append "https://www.rollspel.nu" str)))
(define (link-complete tag body)
(list tag (url-complete (car body))))
(serialize-sxml
`(feed
(@ (xmlns "http://www.w3.org/2005/Atom"))
(title "WRNU Alerts")
(id 62318a60-9791-4e39-9b57-8312c384aaa2)
(updated ,(entry-date (first alerts)))
,@(list-ec (: e alerts)
`(entry
(title ,(html-strip (sxml->html (cdddr (drop-right (sixth (fourth e)) 3)))))
(id ,(string-append "8312c384aaa2-" (cadar ((sxpath "//@data-alert-id") e))))
,@(let ((hrefs ((sxpath "//@href") e)))
(if (null? hrefs)
'()
`((link ,(url-complete (second (last hrefs)))))))
(updated
,(entry-date e))
(content
(@ (type html))
,(sxml->html
(pre-post-order-splice*
(fourth e)
`((src . ,link-complete)
(href . ,link-complete)
(div . ,(lambda (tag body)
(if (null? ((sxpath "time") (cons tag body)))
(cons tag body)
'())))
(*text* . ,(lambda (tag body) body))
(*default* . ,cons)))))
(author
(name ,(let ((author (html-strip (sxml->html ((sxpath "//a[contains(@class, \"username\")]") e)))))
(if (equal? "" author) "WRNU system" author)))))))
output: "/tmp/wrnualert.xml")
Last edited: