From b00955caea60211ebb916053f83fcaf9d80d958e Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Thu, 30 Aug 2012 23:52:39 -0400 Subject: [PATCH] fixed category links with sxml attribute modifier --- links.rkt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/links.rkt b/links.rkt index 19f3aad..e26ba67 100644 --- a/links.rkt +++ b/links.rkt @@ -48,11 +48,17 @@ (define add-breaks (sxml:modify (list "a" 'insert-following `(br "")))) +(define (fixlink node) + (let* ([oldlink (cadar (sxml:attr-list node))] + [newlink (format "http://~a:8080~a?p=1" hostname oldlink)]) + (sxml:set-attr node (list 'href newlink)))) + + (define (parse-category-chunk chunk) (let* ([links (sxpath "//li/div/h3/a")] [descriptions (sxpath "//p")] [html (port->string (get-pure-port (string->url chunk)))] - [result (links (html->shtml html))]) + [result (map fixlink (links (html->shtml html)))]) (match result ['() '()] [_ @@ -74,9 +80,9 @@ pages))) (define (get-category category) - (define-values (drama.next drama.url drama.category drama.id) (make-category-url category 1)) + (define-values (cat.next cat.url cat.category cat.id) (make-category-url category 1)) (string-join - (reverse (get-category-list drama.next (drama.url) drama.category)) "")) + (reverse (get-category-list cat.next (cat.url) cat.category)) "")) ;; Category Stuff ends...