wikipedia: quick-and-dirty article printing.
parent
05f3092b9b
commit
a4f78c9515
|
@ -1,9 +1,12 @@
|
|||
! Copyright (C) 2012 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: accessors assocs calendar colors.constants formatting
|
||||
http.client io io.styles kernel make sequences urls xml
|
||||
xml.data xml.traversal ;
|
||||
USING: accessors ascii assocs calendar colors.constants
|
||||
formatting html.parser html.parser.analyzer html.parser.printer
|
||||
http.client io io.streams.string io.styles kernel make regexp
|
||||
sequences splitting urls wrap.strings xml xml.data
|
||||
xml.traversal ;
|
||||
FROM: xml.data => tag? ;
|
||||
|
||||
IN: wikipedia
|
||||
|
||||
|
@ -61,3 +64,14 @@ PRIVATE>
|
|||
|
||||
: historical-deaths. ( timestamp -- )
|
||||
(historical-events) "Deaths" header. fourth items. ;
|
||||
|
||||
: article. ( name -- )
|
||||
"http://en.wikipedia.org/wiki/%s" sprintf
|
||||
http-get nip parse-html "content" find-by-id-between
|
||||
[ html-text. ] with-string-writer string-lines
|
||||
[ [ blank? ] trim ] map harvest [
|
||||
R/ </ "<" re-replace
|
||||
R/ >/ ">" re-replace
|
||||
R/ &/ "&" re-replace
|
||||
72 wrap-string print nl
|
||||
] each ;
|
||||
|
|
Loading…
Reference in New Issue